Print/Save Keras 中自动编码器生成的特征
Print/Save autoencoder generated features in Keras
我有这个自动编码器:
input_dim = Input(shape=(10,))
encoded1 = Dense(30, activation = 'relu')(input_dim)
encoded2 = Dense(20, activation = 'relu')(encoded1)
encoded3 = Dense(10, activation = 'relu')(encoded2)
encoded4 = Dense(6, activation = 'relu')(encoded3)
decoded1 = Dense(10, activation = 'relu')(encoded4)
decoded2 = Dense(20, activation = 'relu')(decoded1)
decoded3 = Dense(30, activation = 'relu')(decoded2)
decoded4 = Dense(ncol, activation = 'sigmoid')(decoded3)
autoencoder = Model(input = input_dim, output = decoded4)
autoencoder.compile(-...)
autoencoder.fit(...)
现在我想打印或保存在 encoded4 中生成的特征。
基本上,从一个巨大的数据集开始,我想在训练部分之后提取自动编码器生成的特征,以获得我的数据集的受限表示。
你能帮帮我吗?
您可以通过创建 "encoder" 模型来实现:
encoder = Model(input = input_dim, output = encoded4)
这将使用您使用自动编码器训练的相同图层实例,如果您在 "inference mode" 中使用它应该会生成该功能,例如 encoder.predict()
希望对您有所帮助:)
所以,基本上,通过创建这样的编码器:
encoder = Model (input_dim,encoded4)
encoded_input=Input(shape=(6,))
然后使用:
encoded_data=encoder.predict(data)
其中 predict
函数中的数据是数据集,输出由
生成
print encoded_data
是我的数据集的限制表示。
是吗?
谢谢
我有这个自动编码器:
input_dim = Input(shape=(10,))
encoded1 = Dense(30, activation = 'relu')(input_dim)
encoded2 = Dense(20, activation = 'relu')(encoded1)
encoded3 = Dense(10, activation = 'relu')(encoded2)
encoded4 = Dense(6, activation = 'relu')(encoded3)
decoded1 = Dense(10, activation = 'relu')(encoded4)
decoded2 = Dense(20, activation = 'relu')(decoded1)
decoded3 = Dense(30, activation = 'relu')(decoded2)
decoded4 = Dense(ncol, activation = 'sigmoid')(decoded3)
autoencoder = Model(input = input_dim, output = decoded4)
autoencoder.compile(-...)
autoencoder.fit(...)
现在我想打印或保存在 encoded4 中生成的特征。 基本上,从一个巨大的数据集开始,我想在训练部分之后提取自动编码器生成的特征,以获得我的数据集的受限表示。
你能帮帮我吗?
您可以通过创建 "encoder" 模型来实现:
encoder = Model(input = input_dim, output = encoded4)
这将使用您使用自动编码器训练的相同图层实例,如果您在 "inference mode" 中使用它应该会生成该功能,例如 encoder.predict()
希望对您有所帮助:)
所以,基本上,通过创建这样的编码器:
encoder = Model (input_dim,encoded4)
encoded_input=Input(shape=(6,))
然后使用:
encoded_data=encoder.predict(data)
其中 predict
函数中的数据是数据集,输出由
print encoded_data
是我的数据集的限制表示。
是吗?
谢谢