Keras中VDSR的残余损耗的计算

时间:2018-12-20 08:54:20

标签: tensorflow keras

我在后端Tensorflow上使用Keras。我从(https://github.com/GeorgeSeif/VDSR-Keras)下载了非常深的超分辨率cnn的代码,并尝试训练自己的模型。该模型使用均方误差(mse)进行编译,但是原始模型具有残差。如何在喀拉拉邦实现剩余损失。剩余损失可以计算为

loss = (label - input_image - predected_image)^2

2 个答案:

答案 0 :(得分:0)

您可以创建自定义损失函数并进行分配。 我不确定残留损失的工作原理,但是如果您能够计算出来,您可以像这样实现。

<?php
$gendate = new DateTime();
$gendate->setISODate(2019,1,3); //year , week num , day
echo $gendate->format('Y-m-d'); //"prints"  2019-01-02

答案 1 :(得分:0)

VDSR模型如下:

input_img = Input(shape=IMG_SIZE)

model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(input_img)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)

model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)

model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)

model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(64, (3, 3), padding='same', kernel_initializer='he_normal')(model)
model = Activation('relu')(model)
model = Conv2D(1, (3, 3), padding='same', kernel_initializer='he_normal')(model)
res_img = model

output_img = add([res_img, input_img])

model = Model(input_img, output_img)

模型的输入图像是一块图像块(一个块的分辨率为41 x 41像素,每像素8位)。
在您的公式中: loss =(label-input_image-predected_image)^ 2 =(label-(input_image + predected_image))^ 2)其中input_image + predected_image是newtork输出。网络学习对缩放后的输入图像进行校正(线output_img = add([res_img,input_img])),以克服双三次插值的影响,这不是图像超分辨率的最佳方法。