loss 目标函数
metric 评价指标
# 方式一 注意编译 loss = 你定义的损失函数的名字
# 方式二 注意使用 K.log K.sigmoid
def vae_loss(x, x_decoded_mean):
xent_loss = objectives.binary_crossentropy(x, x_decoded_mean)
kl_loss = - 0.5 * K.mean(1 + z_log_sigma - K.square(z_mean) - K.exp(z_log_sigma), axis=-1)
return xent_loss + kl_loss
vae.compile(optimizer='rmsprop', loss=vae_loss)
参考:
1, keras 自定义 loss损失函数, sample在loss上的加权 和 metric
https://blog.csdn.net/xiaojiajia007/article/details/73274669/
2, Unet项目解析(7): 模型编译-优化函数、损失函数、指标列表
https://blog.csdn.net/shenziheng1/article/details/80715264
3, (Keras)——Keras中自定义目标函数(损失函数)
https://blog.csdn.net/wangdongwei0/article/details/82563689
4, Using binary_crossentropy loss in Keras (Tensorflow backend)
5, 深度学习基础系列(五)| 深入理解交叉熵函数及其在tensorflow和keras中的实现
http://www.cnblogs.com/hutao722/p/9761387.html
6, 目标函数objectives
https://keras-cn.readthedocs.io/en/latest/legacy/other/objectives/