Closed schlerp closed 5 years ago
Ok, thanks for the recommendation! I was not sure how to get around the issue of not knowing batch size at runtime, this makes a lot of sense. I will try to update the repo when I have some free time.
Note your refactoring of KLD needs fixing to remain compatible with https://github.com/alecGraves/BVAE-tf/issues/3
heyo,
really like your implementation but noticed the static batch size was causing me all sorts of grief when i wanted to play around with training. after a bit of mucking around i came up with a solution that i feel is a little more elegant.
basically the issue arises because during construction there is a call to the instantiated layer. at that point the tensor being passed in as "x" to the sampling layers call() function has an undefined batch_size. at build time all we need to do is return a tensor with the appopriate shape, we dont actually need to call the K.random_normal() function which is the only part of this function that needs the batch_size explicitly.
long story short, stick this in your Sampling.call() function:
in context that is (i made some slight other changes to function but you can ignore them, this is just so you can see how y fix would fit into the function):