Lasagne / Recipes

Lasagne recipes: examples, IPython notebooks, ...
MIT License
914 stars 418 forks source link

densenet example: avoid a float64 cast #100

Closed danstowell closed 7 years ago

danstowell commented 7 years ago

It appears that this particular mean() operation causes a float64 cast unless you tell it not to. I have warn_float64=raise in my .theanorc and so it raises an exception about it. (I'm using recent master of lasagne+theano, on ubuntu.)

I have not tested whether this change affects convergence.

f0k commented 7 years ago

I have not tested whether this change affects convergence.

It cannot, it's just to monitor performance on the validation set. In this case it also doesn't matter whether it's float64 or float32 (the value is returned in the end, and it's of no practical importance whether the mean is computed on GPU and then transferred to CPU or the tensor is transferred first and then averaged over). You should use warn_float64 during development to make sure there are no unintentional casts, but then you can disable it. I'm still fine with your change if you make it conform to pep8 (the line is too long, I'd suggest a new line with a double indent for the new mean() argument). Please amend your commit instead of adding a second one (let me know if you need help with this). Thanks!

danstowell commented 7 years ago

Like this? (Formatting)

True that warn_float64 is can be disabled, but IMHO this repository's code shouldn't require users to do things like that when not necessary. Lucky the fix is easy.

f0k commented 7 years ago

Like this? (Formatting)

I was thinking about a double indent (8 chars). A hanging indent has to have at least 4 characters, but anything greater is fine (and makes it easier to distinguish from a code-level indent). I opted for a more creative hanging indent now to avoid the large horizontal gap between mean( and its argument. Merging, thanks again!