Layer conv2d_3 was called with an input that isn't a symbolic tensor

后端 未结 1 1791

hi I am building a image classifier for one-class classification in which i\'ve used autoencoder while running this model I am getting this error (ValueError: Layer conv2d_3

1条回答
  •  攒了一身酷
    2020-12-11 09:44

    Here:

    x = Conv2D(16, (3, 3), activation='relu', padding='same')(input_shape)
    

    A shape is not a tensor.

    Do this:

    from keras.layers import *
    inputTensor = Input(input_shape)
    x = Conv2D(16, (3, 3), activation='relu', padding='same')(inputTensor)
    

    Hint about autoencoders

    You should separate the encoder and decoder as individual models. Later you will probably want to work with only one of them.

    Encoder:

    inputTensor = Input(input_shape)
    x = ....
    encodedData = MaxPooling2D((2, 2), padding='same')(x)
    
    encoderModel = Model(inputTensor,encodedData)
    

    Decoder:

    encodedInput = Input((4,4,8))
    x = ....
    decodedData = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(x)
    
    decoderModel = Model(encodedInput,decodedData)
    

    Autoencoder:

    autoencoderInput = Input(input_shape)
    encoded = encoderModel(autoencoderInput)
    decoded = decoderModel(encoded)
    
    autoencoderModel = Model(autoencoderInput,decoded)
    

    0 讨论(0)
提交回复
热议问题