https://github.com/andrewgordonwilson/bayesgan/blob/ca06613201e0882a21e53f18e71ecbff5eda7923/bgan.py#L277