inputLayer = tf.keras.layers.Input(shape=(500,))
编码层
encoded = tf.keras.layers.Dense(128, activation=ACTIVATION)(inputLayer)
encoder_output = tf.keras.layers.Dense(64, activation=ACTIVATION)(encoded)
LR = tf.keras.layers.Dense(10, activation=ACTIVATION_SORT)(encoder_output)
解码层
decoded = tf.keras.layers.Dense(64, activation=ACTIVATION)(encoder_output)
decoded = tf.keras.layers.Dense(128, activation=ACTIVATION)(decoded)
decoded = tf.keras.layers.Dense(500, activation='sigmoid')(decoded)
构建自编码模型:
autoencoder = tf.keras.Model(inputs=inputLayer, outputs=decoded)
autoencoder.compile(optimizer='adam', loss='mse')
hist = autoencoder.fit(x_train, x_train, epochs=200, batch_size=512, shuffle=True)
保留编码器:
encoder = tf.keras.Model(inputs=inputLayer, outputs=LR)
提问:autoencoder做不做训练,对下面的encoder有影响吗?