kasparmartens / neuralprocesses Goto Github PK
View Code? Open in Web Editor NEWNeural Processes implementation for 1D regression
Neural Processes implementation for 1D regression
Hi Kaspar,
I tried replicating the results in your post in PyTorch, and I'm unable to get even close to the kind of results you display on your blog. I am sure there is an error on my end somewhere, but I have poured over the paper and your code and your blog post and I'm unable to see anything that could be behind it. I had a friend look over my implementation too and were unable to spot anything of substance different.
I have tried as best as possible to follow the architecture and setup of your experiment 1, and I see very different behavior. The code is very simple, It's afterall only a handful of simple nns,
https://github.com/chrisorm/Machine-Learning/blob/ngp/Neural%20GP.ipynb
Some things I witness that you don't seem to see (shown in the notebook):
-My q distribution concentrates (i.e. std goes to 0).
The first led me to suspect an error in my KLD term, but that does not seem to be the case - I unit tested my implementation and I think it is correct. The loss looks good and the network clearly converges.
The second is a bit stranger - do you perhaps use some particular initialization of the weights to draw these samples, over and above setting z ~ N(0,1)?
Would you happen to have any insights as to what may be behind this difference?
Thanks for taking the time to do your post, it has some really great insights into the method!
Chris
I believe there is a mistake in the way that you calculate the KL-divergence. The log term should be subtracted instead of added.
KLqp_gaussian <- function(mu_q, sigma_q, mu_p, sigma_p){
sigma2_q <- tf$square(sigma_q) + 1e-16
sigma2_p <- tf$square(sigma_p) + 1e-16
temp <- sigma2_q / sigma2_p + tf$square(mu_q - mu_p) / sigma2_p - 1.0 - tf$log(sigma2_p / sigma2_q + 1e-16)
0.5 * tf$reduce_sum(temp)
}
I think your coding about NP exists several problems. I suggest you should check your code again and again.
If we wanted to make this bit
NeuralProcesses/NP_architecture2.R
Lines 68 to 71 in 5119ac0
Hi Kaspar,
Thank you so much for sharing your code! I have implemented a tensorflow version and it works well on sin functions. However, when it comes to the functions sampled from gaussian processes, the prediction cannot capture the complexity of the functions. Have you had similar problem?
Thank you!
Yangg-S
Did you try to do the MNIST image completion task with your neural process implementation? I also recently implemented NP (in PyTorch), but I can't get it to work for that task. After seeing your code here, I made a version of my own code that should be ~identical to yours (except in PyTorch). I only did your first experiment, but it worked fine. However, the image completion works no better than my previous implementation. I'd be interested to hear about any results that you had on that task / thoughts on what could be failing there (feel free to close this issue if you aren't interested).
Sorry this question might be obvious but I don't understand why n_draws and N_star are taken from [1] from shape. Shouldn't their dimension be taken from [0].
decoder g -- map (z, x*) -> hidden -> y*
-inputs dimensions
-z_sample has dim [n_draws, dim_z]
n_draws <- z_sample$get_shape()$as_list()[1]
N_star <- tf$shape(x_star)[1]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.