variational_autoencoder_deconv.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:VAE_NOTES 作者: FanhuaandLuomu 项目源码 文件源码
def vae_loss(x, x_decoded_mean):
    # NOTE: binary_crossentropy expects a batch_size by dim
    # for x and x_decoded_mean, so we MUST flatten these!
    # Flatten
    x = K.flatten(x)
    x_decoded_mean = K.flatten(x_decoded_mean)
    xent_loss = img_rows * img_cols * objectives.binary_crossentropy(x, x_decoded_mean)
    kl_loss = - 0.5 * K.mean(1 + z_log_var - K.square(z_mean) - K.exp(z_log_var), axis=-1)
    return xent_loss + kl_loss

# input_shape: (100,1,28,28)
# output_shape: (100,1,28,28)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号