Comments (4)
Update 2: I think the problem is when I pickle and unpickle the model. When I remove this line the problem goes away (but is no longer the correct optimization routine).
The reason I do this is that I want to backpropagate through the inputs of the reversible net but I don't want to modify the weights of the reversible net in that instance. It's basically an EM algorithm where the maximization is a minimization of the KL divergence of two distributions and I don't want to modify the weights of the expectation of the model, but I do want to backpropagate through the samples generated by the P distribution. I'm curious about what my options are to perform this task (like for example a way to perform a deep copy with FrEIA) or if you have a good way to fix the numerical instability that comes with pickling and unpickling repeatedly.
Edit: I tried using model2.load_state_dict(model.state_dict())
instead of pickle, but that still resulted in the same numerical instability
from freia.
Actually correction. It's likely a numerical error because even though: print(torch.all(torch.eq(rev1,samp_t2)))
returns false, the numbers are the same up to 3 decimal places. However when I run the optimization routine in this colab notebook: https://colab.research.google.com/drive/1Ng2TshNYmtloeiUyjQpDeCNxhc_R_2_c?usp=sharing and then forward and reverse, the errors are much more noticeable.
from freia.
Hmm, I'm not quite sure what level of numerical difference is acceptable.
In deep neural networks in general, and also in INNs, something on the order of 10^-4 relative error is not surprising (which it sounds like you are getting)
I didn't quite get what you did with the pickling and unpickling (i.e. if you just checked the numerical inversion error of an untrained model), but as the weights get larger (more specifically the jacobian determinant), the numerical errors tend to grow.
Here is an interesting read on the topic: https://arxiv.org/pdf/2006.09347.pdf
Otherwise, it might also have to do with tranferring the model and weights from and back to the gpu.
Your application sounds very interesting, but maybe it would still work with the currect level of numerical accuracy?
The inaccuracies have never given us big trouble in practice.
I will close the issue for now, seeing as it is over a year old and it is likely your work has moved on, but don't hesitate to re-open it if you want us to go into more detail!
from freia.
Thanks. Yea I don't even remember what this code was for to be honest. I might have found pyro code that helped with it.
from freia.
Related Issues (20)
- Cannot open manual HOT 1
- Nice repo!!
- Incoherence between version
- Tips of this repo says 1x1 convolutions should constitute every other, or every third coupling block. What is this based on? HOT 1
- Add Flow++ HOT 2
- Expect a detailed documentation of this library
- Bug in binned.py
- Error when exporting FrEIA library to ONNX
- Adapt MLP to FrEIA framework HOT 1
- Installation problem, versions HOT 1
- FrEIA.modules.Split incorrect completion of missing dimension when initialized with section_sizes Sequence
- Dimension error about the `SequenceINN` HOT 4
- New version release on PyPI
- Some examples in the documentation are missing HOT 3
- Error in the implementation of ActNormalization HOT 6
- [BUG] Nondeterministic
- [BUG] IndexError: tuple index out of range HOT 2
- ActNorm is incorrectly implemented HOT 4
- Example of GaussianMixtureModel
- RuntimeError: NVML_SUCCESS == r INTERNAL ASSERT FAILED at "/opt/pytorch/pytorch/c10/cuda/CUDACachingAllocator.cpp":830 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freia.