卷积自动编码器的适当损失函数

时间:2021-07-21 22:32:52

标签: python tensorflow autoencoder

所以我有一个看起来像这样的卷积自动编码器架构

def MainEncoder():
    inp = Input(shape=(64,64,3))
    x = Conv2D(256,2)(inp)
    x = MaxPool2D()(x)
    x = Conv2D(128,2)(x)
    x = Flatten()(x)
    encoded = Dense(100,activation="relu")(x)

    encoder= Model(inp,encoded)
    return encoder


def Decoder():
    enc = Input(shape=(100,))
    y = Dense(128)(enc)
    y = Dense(768)(y)
    y= Reshape((16,16,3))(y)
    y= Conv2DTranspose(128,(1,1),(2,2),padding='same')(y)
    y= Conv2DTranspose(128,(1,1),(2,2),padding='same')(y)
    decoded1 = Conv2D(3,1)(y)
    decoder = Model(enc,decoded1)
    return decoder
encoder= MainEncoder()

decoderA = Decoder()
decoderB = Decoder()

print(encoder.summary())
print(decoderA.summary())
#decoder=  Model(encoded_input,decoded1)
#print(decoder.summary())
Inp = Input(shape=(64,64,3))
Inp2 = Input(shape=(64,64,3))

AutoEncoder1 = Model(Inp,decoderA(encoder(Inp)))
AutoEncoder2 = Model(Inp2,decoderB(encoder(Inp2)))

我想知道这种架构的正确损失函数是什么。二元交叉熵依赖于灰度图像(我希望避免这种情况),而分类交叉熵不起作用。

0 个答案:

没有答案