-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add realistic example #38
Conversation
Thanks for starting this. It looks great so far 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @ElliottKasoar
A couple of comments:
- Whilst it is arguably 'cleaner' in terms of storage to fetch the image from url, there is no guarantee it will always be available. Since it is only a single image I would consider just adding it to the repository to make the example self-contained. This will also arguably make the python a bit cleaner.
- Saving the data to file is a good idea, but could we do it more nicely than
.flatten().to_file()
? And consider adding*.dat
to.gitignore
. Also a comment in the docs about writing/reading between row/column major systems for clarity could be really helpful for users' understanding.
@jatkinson1000 What sort of thing would you consider to be nicer? My feeling was that flattening it would make it the least ambiguous, or do you mean the way it is flattened/saved? (I'll add a commend about writing/reading anyway) |
What about something in between (which I'm halfway along, having added the .jpg to the PR): try to download the data, but, if necessary, catch the I quite like having some form of the fetch present, as, for example, I wanted to test a different dog, which only requires changing one line of code at the moment, and I think it makes an example better if the barrier to trying out different data is as low as possible. |
Yes, testing alternative images did cross my mind, but the purpose of this example is to serve as an (ideally minimal) example of how to save a pytorch net and couple it to Fortran. To this end I'd maybe favour having the image in the repo to read from and removing the requests code, perhaps with a note in the Readme to describe how a user might go about trying other images. |
For the MiMA case we wrote out with the indices with the value (e.g. see here) to remove any ambiguity when reading back in and make interpretable. |
As discussed with @TomMelt and @jatkinson1000:
|
At some point @TomMelt mentioned that it would be nice to have an assert to check that the results are actually consistent e.g. Given that the probabilities are more complex than that example, and seem to only match to ~5sf, is it worth just adding an assert for the label? Or maybe we should check the first 4-5 significant figures of the probability? |
Yes, @ElliottKasoar, something like (checks relative error):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking pretty good, nice work reading the categories etc. in to Fortran to make it a complete example!
Couple of comments as below.
Also, the python code could be more black, pylint, and mypy compliant.
aca0a77
to
46bbc78
Compare
Was there anything obvious that you haven't mentioned? I'd already run it my main changes to resnet18.py through flake8 and black, and I think there were only a couple of minor things in resnet_infer_python.py, which I hadn't looked at enough yet (as part of the last set of changes, it's now updated to use the new image, as it was still using the I've made a few more minor changes based on a few things from pylint/mypy too in the last commit, so hopefully it's ok now? |
The snippet of subroutine assert_real_2d(a, b, test_name, rtol_opt)
implicit none
character(len=*) :: test_name
real, intent(in), dimension(:,:) :: a, b
real, optional :: rtol_opt
real :: relative_error, rtol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this now, and all running fine under checks for me.
I'll let @TomMelt take a look as well since it's been a large PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just need to tidy up some fortran variable attributes
Thanks @TomMelt! I think addressed all of your Fortran variable suggestions. I also wanted to double check you were happy with the changes just before/at the same time as your review along side the assertion checks, which included the addition of |
Fixes #32
Replaces the example ones tensor with a more realistic example, based on a Pytorch Resnet example.
To do: