leongatys / PytorchNeuralStyleTransfer

Implementation of Neural Style Transfer in Pytorch
MIT License
421 stars 103 forks source link

division by zero error on L-BGFS / python3.6 no cuda #5

Closed javiervdp closed 6 years ago

javiervdp commented 6 years ago

Thanks for the code Leon, cloning and running on linux, python 3.6 with cuda, works just fine for source images or any other img i threw at this. Running on py3.6 no cuda on a mac I got a division by zero on the optimizer Not that it makes any sense to run this without cuda but thought you ought to know. Running it with RMSProp this worked - although results were less pronounced.

ZeroDivisionError Traceback (most recent call last)

in () 20 return loss 21 ---> 22 optimizer.step(closure) 23 24 #display result ~/anaconda3/envs/abc/lib/python3.6/site-packages/torch/optim/lbfgs.py in step(self, closure) 151 152 # update scale of initial Hessian approximation --> 153 H_diag = ys / y.dot(y) # (y*y) 154 155 # compute the approximate (L-BFGS) inverse Hessian ZeroDivisionError: float division by zero
leongatys commented 6 years ago

Hi, thanks for letting me know, I have seen strange behavior when running this on the CPU before and I am not quite sure what the reason for this is. My guess is that the BFGS implementation on CPU is in some way different to the GPU one that leads to instabilities.

Best Leon