我有一个很大的模型,其中包含很多损失和指标。
当我做print(np.array(self.model.metrics_names))
时
我明白了:
['loss' 'autoencoder_loss' 'autoencoder_loss' 'autoencoder_loss'
'autoencoder_loss' 's_regularisation_phase_loss'
'gen_regularisation_phase_loss' 's_regularisation_phase_loss'
'z_regularisation_phase_loss' 'gen_regularisation_phase_loss'
'z_regularisation_phase_loss' 'gen_regularisation_phase_loss'
'gen_regularisation_phase_loss' 'autoencoder_categorical_accuracy'
'autoencoder_output' 'autoencoder_categorical_accuracy_1'
'autoencoder_output_1' 'autoencoder_categorical_accuracy_2'
'autoencoder_output_2' 'autoencoder_categorical_accuracy_3'
'autoencoder_output_3' 's_regularisation_phase_categorical_accuracy'
's_regularisation_phase_output'
'gen_regularisation_phase_categorical_accuracy'
'gen_regularisation_phase_output'
's_regularisation_phase_categorical_accuracy_1'
's_regularisation_phase_output_1'
'z_regularisation_phase_categorical_accuracy'
'z_regularisation_phase_output'
'gen_regularisation_phase_categorical_accuracy_1'
'gen_regularisation_phase_output_1'
'z_regularisation_phase_categorical_accuracy_1'
'z_regularisation_phase_output_1'
'gen_regularisation_phase_categorical_accuracy_2'
'gen_regularisation_phase_output_2'
'gen_regularisation_phase_categorical_accuracy_3'
'gen_regularisation_phase_output_3']
有没有办法给他们起更有意义的名字?
答案 0 :(得分:0)
每个_loss
和_accuracy
之前的名称都来自输出图层的名称。如果要修改此名称,则应重命名输出层。
请考虑以下模型。
input_ = keras.layers.Input(shape=(8,))
x = keras.layers.Dense(16)(input_)
output1 = keras.layers.Dense(32, name="output1")(x)
output2 = keras.layers.Dense(32, name="output2")(x)
model = keras.models.Model(inputs=input_, outputs=[output1, output2])
model.compile(loss=["mse", "mae"], optimizer="adam", metrics={"output1":"accuracy","output2":"accuracy"})
现在model.metrics_names
将为您提供以下列表
['loss', 'output1_loss', 'output2_loss', 'output1_acc', 'output2_acc']