NVlabs / DeepInversion

Official PyTorch implementation of Dreaming to Distill: Data-free Knowledge Transfer via DeepInversion (CVPR 2020)
Other
488 stars 79 forks source link

Replaced apex.amp with torch.cuda.amp and Tensor.view() with Tensor.reshape() #19

Closed francescodisalvo05 closed 3 years ago

francescodisalvo05 commented 3 years ago

I cloned and run the code on Google Colab and I faced two problems:

The first one was caused by "apex.amp" and it was the following one: cannot import name 'UnencryptedCookieSessionFactoryConfig' from 'pyramid.session' I was able to run the code by replacing apex.amp with torch.cuda.amp in both deepinversion.py and imagenet_inversion.py

The second one was caused by Tensor.view(): RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

So I replaced in imagenet_inversion.py (line 47) correct_k = correct[:k].view(-1).float().sum(0) with correct_k = correct[:k].reshape(-1).float().sum(0)

Thanks to these two adjustements I was able to run the code without any further problems.

pamolchanov commented 3 years ago

Thank you very much!

francescodisalvo05 commented 3 years ago

Thank you very much!

It's a pleasure, thank you for your wonderful work!