我正在尝试从自动编码器中复制该图层以用于解码文件,但出现错误
encoded_input = Input(shape=(50,))
decoder_layer = autoencoder.layers[-1](encoded_input)
decoder = Model(50, decoder_layer)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')
autoencoder.fit(X, X,
epochs=50,
shuffle=True)
我希望复制该图层,以便可以解码文件,但是出现此错误:
Traceback (most recent call last):
File "C:\Users\dalto\Documents\geo4\train.py", line 36, in <module>
decoder = Model(50, decoder_layer)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training.py", line 133, in __init__
super(Model, self).__init__(*args, **kwargs)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\network.py", line 161, in __init__
self._init_graph_network(*args, **kwargs)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\training\tracking\base.py", line 458, in _method_wrapper
result = method(self, *args, **kwargs)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\network.py", line 270, in _init_graph_network
self._validate_graph_inputs_and_outputs()
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\network.py", line 1521, in _validate_graph_inputs_and_outputs
' (missing previous layer metadata).')
ValueError:模型的输入张量必须来自tf.keras.Input
。已收到:50(缺少上一层元数据)。