【发布时间】:2017-07-09 15:07:57
【问题描述】:
我正在尝试使用 Keras(带有 Tensorflow 后端)采用香草自动编码器,并在损失值收敛到特定值时停止它。在最后一个 epoch 之后,我想使用 sigmoid 函数来执行分类。你知道怎么做吗(或者至少给我指出正确的方向)?
下面的代码与http://wiseodd.github.io/techblog/2016/12/03/autoencoders/ 的普通自动编码器非常相似。 (我使用的是我自己的数据,但请随意使用链接中的 MNIST 示例来演示您在说什么。)
NUM_ROWS = len(x_train)
NUM_COLS = len(x_train[0])
inputs = Input(shape=(NUM_COLS, ))
h = Dense(64, activation='sigmoid')(inputs)
outputs = Dense(NUM_COLS)(h)
# trying to add last sigmoid layer
outputs = Dense(1)
outputs = Activation('sigmoid')
model = Model(input=inputs, output=outputs)
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
model.fit(x_train, y_train,
batch_size=batch,
epochs=epochs,
validation_data=(x_test, y_test))
【问题讨论】:
-
您好,您的 x_train 是什么,y_train 是什么?这看起来不像自动编码器
-
请看链接中的示例。如果我让它在这方面发挥作用,我就能让它在我的数据上发挥作用。
-
让我换个方式提出同样的问题:你想用自动编码器实现什么。您可以使用标准分类模型。
标签: machine-learning neural-network deep-learning keras autoencoder