我有这个自动编码器:
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(...)
Run Code Online (Sandbox Code Playgroud)
现在我想打印或保存在编码4中生成的功能。基本上,从一个巨大的数据集开始,我想在训练部分之后提取自动编码器生成的特征,以获得我的数据集的受限表示。
你可以帮帮我吗?
我已经训练了一个 keras CNN 监控指标如下:
METRICS = [
TruePositives(name='tp'),
FalsePositives(name='fp'),
TrueNegatives(name='tn'),
FalseNegatives(name='fn'),
BinaryAccuracy(name='accuracy'),
Precision(name='precision'),
Recall(name='recall'),
AUC(name='auc'),
]
Run Code Online (Sandbox Code Playgroud)
然后是model.compile:
model.compile(optimizer='nadam', loss='binary_crossentropy',
metrics=METRICS)
Run Code Online (Sandbox Code Playgroud)
它工作得很好,我保存了我的 h5 模型(model.h5)。
现在我已经下载了模型,我想在其他脚本中使用它来导入模型:
from keras.models import load_model
model = load_model('model.h5')
model.predict(....)
Run Code Online (Sandbox Code Playgroud)
但在运行期间编译器返回:
ValueError: Unknown metric function: {'class_name': 'TruePositives', 'config': {'name': 'tp', 'dtype': 'float32', 'thresholds': None}}
Run Code Online (Sandbox Code Playgroud)
我应该如何管理这个问题?
先感谢您