vgg编码器_使用自动编码器计算感知损失而不是图像分类器(VGG-16)

对于生成对抗网络的培训我正在使用Perceptual_Loss函数 . Perceptual_Loss是用于在识别图像的特征之后找出两个图像是否彼此相似的函数 . 如上所述here我们可以使用图像分类器和自动编码器来识别特征 . 大多数开发人员使用 VGG16 作为图像分类器来计算Perceptual_Loss . 我想使用预先训练过的自动编码器(我自己训练) . 使用预先训练的自动编码器权重我已将以下原始Perceptual_Loss函数更改为

#### Original Perceptual Loss Function ####

from keras.applications.vgg16 import VGG16

def perceptual_loss(y_true, y_pred):

vgg = VGG16(include_top=False, weights='imagenet', input_shape=(256,256,3))

loss_model = Model(inputs=vgg.input, outputs=vgg.get_layer('block3_conv3').output)

loss_model.trainable = False

return K.mean(K.square(loss_model(y_true) - loss_model(y_pred)))

#### My Perceptual Loss Function ####

trained_autoencoder=load_model('Path/AutoEncoder_Model.h5')

trained_autoencoder.compile(loss='mean_squared_error', optimizer='adadelta')

def perceptual_loss(y_true, y_pred):

return K.mean(K.square(trained_autoencoder.predict(y_true) - trained_autoencoder.predict(y_pred)))

但它给了我这个错误

**When feeding symbolic tensors to a model, we expect thetensors to have a static batch size. Got tensor with shape: (None, None, None, None)**

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值