Keras 去噪自动编码器(表格数据)
Keras Denoising Autoencoder (tabular data)
我有一个项目,我正在使用表格数据对梯度提升树进行回归。我想看看对我的数据使用降噪自动编码器是否可以更好地表示我的原始数据并提高我的原始 GBT 分数。灵感来自流行的 Kaggle 冠军 here.
AFAIK 对于提取 DAE 的激活,我有两个主要选择 - 创建瓶颈结构并采用单个中间层激活或连接每个层的激活作为表示。
假设我想要来自以下 3x 512 个节点层的所有层激活:
inputs = Input(shape=(31,))
encoded = Dense(512, activation='relu')(inputs)
encoded = Dense(512, activation='relu')(encoded)
decoded = Dense(512, activation='relu')(encoded)
decoded = Dense(31, activation='linear')(decoded)
autoencoder = Model(inputs, decoded)
autoencoder.compile(optimizer='Adam', loss='mse')
history = autoencoder.fit(x_train_noisy, x_train_clean,
epochs=100,
batch_size=128,
shuffle=True,
validation_data=(x_test_noisy, x_test_clean),
callbacks=[reduce_lr])
我的问题是:
对上述进行激活会得到 x_train 的新表示,对吗?我应该为 x_test 重复这个过程吗?我需要两者来训练我的 GBT 模型。
如何进行推理?每个新数据点都需要 "converted" 进入这种新的表示格式。我如何使用 Keras 做到这一点?
在这种情况下,我真的需要向 .fit
提供 validation_data=
吗?
Taking the activations of the above will give me a new representation
of x_train, right? Should I repeat this process for x_test? I need
both to train my GBT model.
当然,训练数据和测试数据都需要去噪表示,因为后面训练的GBT模型只接受去噪后的特征。
How can I do inference? Each new data point will need to be
"converted" into this new representation format. How can I do that
with Keras?
如果要使用denoised/reconstructed特征,可以直接使用autoencoder.predict( X_feat )
提取特征。如果要使用中间层,需要先建立一个新的模型encoder_only=Model(inputs, encoded)
,然后用它来进行特征提取。
Do I actually need to provide validation_data= to .fit in this
situation?
最好分离出一些训练数据进行验证,防止过拟合。但是,您始终可以训练多个模型,例如以留一法的方式以整体方式充分利用所有数据。
补充说明:
- 512 个隐藏神经元对于您的任务来说似乎太多了
- 考虑使用
DropOut
- 注意表格数据,尤其是当不同列中的数据具有不同的动态范围时(即 MSE 没有公平地量化不同列的重建误差)。
Denoising autoencoder model是一种可以帮助对噪声数据进行去噪的模型。作为训练数据,我们使用我们的训练数据和目标相同的数据。
您上面描述的模型不是去噪自动编码器模型。对于自动编码器模型,在编码部分,单元的数量必须逐层逐渐减少,因此在解码部分,单元的数量必须逐渐增加。
简单的自动编码器模型应该如下所示:
input = Input(shape=(31,))
encoded = Dense(128, activation='relu')(input)
encoded = Dense(64, activation='relu')(encoded)
encoded = Dense(32, activation='relu')(encoded)
decoded = Dense(32, activation='relu')(encoded)
decoded = Dense(64, activation='relu')(decoded)
decoded = Dense(128, activation='relu')(decoded)
decoded = Dense(31, activation='sigmoid')(decoded)
autoencoder = Model(input, decoded)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(x_train_noisy, x_train_noisy,
epochs=100,
batch_size=256,
shuffle=True,
validation_data=(x_test_noisy, x_test_noisy))
我有一个项目,我正在使用表格数据对梯度提升树进行回归。我想看看对我的数据使用降噪自动编码器是否可以更好地表示我的原始数据并提高我的原始 GBT 分数。灵感来自流行的 Kaggle 冠军 here.
AFAIK 对于提取 DAE 的激活,我有两个主要选择 - 创建瓶颈结构并采用单个中间层激活或连接每个层的激活作为表示。
假设我想要来自以下 3x 512 个节点层的所有层激活:
inputs = Input(shape=(31,))
encoded = Dense(512, activation='relu')(inputs)
encoded = Dense(512, activation='relu')(encoded)
decoded = Dense(512, activation='relu')(encoded)
decoded = Dense(31, activation='linear')(decoded)
autoencoder = Model(inputs, decoded)
autoencoder.compile(optimizer='Adam', loss='mse')
history = autoencoder.fit(x_train_noisy, x_train_clean,
epochs=100,
batch_size=128,
shuffle=True,
validation_data=(x_test_noisy, x_test_clean),
callbacks=[reduce_lr])
我的问题是:
对上述进行激活会得到 x_train 的新表示,对吗?我应该为 x_test 重复这个过程吗?我需要两者来训练我的 GBT 模型。
如何进行推理?每个新数据点都需要 "converted" 进入这种新的表示格式。我如何使用 Keras 做到这一点?
在这种情况下,我真的需要向
.fit
提供validation_data=
吗?
Taking the activations of the above will give me a new representation of x_train, right? Should I repeat this process for x_test? I need both to train my GBT model.
当然,训练数据和测试数据都需要去噪表示,因为后面训练的GBT模型只接受去噪后的特征。
How can I do inference? Each new data point will need to be "converted" into this new representation format. How can I do that with Keras?
如果要使用denoised/reconstructed特征,可以直接使用autoencoder.predict( X_feat )
提取特征。如果要使用中间层,需要先建立一个新的模型encoder_only=Model(inputs, encoded)
,然后用它来进行特征提取。
Do I actually need to provide validation_data= to .fit in this situation?
最好分离出一些训练数据进行验证,防止过拟合。但是,您始终可以训练多个模型,例如以留一法的方式以整体方式充分利用所有数据。
补充说明:
- 512 个隐藏神经元对于您的任务来说似乎太多了
- 考虑使用
DropOut
- 注意表格数据,尤其是当不同列中的数据具有不同的动态范围时(即 MSE 没有公平地量化不同列的重建误差)。
Denoising autoencoder model是一种可以帮助对噪声数据进行去噪的模型。作为训练数据,我们使用我们的训练数据和目标相同的数据。
您上面描述的模型不是去噪自动编码器模型。对于自动编码器模型,在编码部分,单元的数量必须逐层逐渐减少,因此在解码部分,单元的数量必须逐渐增加。
简单的自动编码器模型应该如下所示:
input = Input(shape=(31,))
encoded = Dense(128, activation='relu')(input)
encoded = Dense(64, activation='relu')(encoded)
encoded = Dense(32, activation='relu')(encoded)
decoded = Dense(32, activation='relu')(encoded)
decoded = Dense(64, activation='relu')(decoded)
decoded = Dense(128, activation='relu')(decoded)
decoded = Dense(31, activation='sigmoid')(decoded)
autoencoder = Model(input, decoded)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(x_train_noisy, x_train_noisy,
epochs=100,
batch_size=256,
shuffle=True,
validation_data=(x_test_noisy, x_test_noisy))