过去几周我一直在问你自动编码器的问题。 今天的问题如下; 如何从瓶颈层获取功能?
我已经推荐过这个网站。 https://github.com/keras-team/keras/issues/2495
我收到的错误信息在这里显示;
UserWarning:更新您对Keras 2 API的Model
电话:Model(inputs=[<tf.Tenso..., outputs=[<tf.Tenso...)
模型(输入= [输入],输出= [中间层])
此外,我尝试使用此方法提取功能(请参阅下面的链接),但它也无法正常工作。 https://keras.io/getting-started/faq/#how-can-i-obtain-the-output-of-an-intermediate-layer
任何评论都应该有所帮助。 谢谢!
X = Input(shape=(37310,))
encoded = Dense(encoding_dim, activation='tanh')(X)
decoded = Dense(37310, activation='sigmoid')(encoded)
autoencoder = Model(X, decoded)
encoded_input = Input(shape=(encoding_dim,))
decoder_layer = autoencoder.layers[-1]
decoder = Model(encoded_input, decoder_layer(encoded_input))
autoencoder.compile(optimizer='SGD', loss='mean_squared_error')
encoded1 = Dense(500, activation='tanh')(X)
encoded2 = Dense(100, activation='tanh')(encoded1)
encoded3 = Dense(50, activation='tanh')(encoded2)
decoded = Dense(100, activation='tanh')(encoded)
decoded = Dense(500, activation='tanh')(decoded)
decoded = Dense(37310, activation='sigmoid')(decoded)
autoencoder = Model(X, decoded)
autoencoder.compile(optimizer='SGD', loss='mean_squared_error')
autoencoder.fit(X_train, X_train,
epochs=10,
batch_size=100,
shuffle=True,
validation_data=(X_test, X_test))
model = Model(input=[X], output=[encoded3])