gpt4 book ai didi

python - 有没有办法重命名 Keras 模型的指标和损失?

转载 作者:行者123 更新时间:2023-11-30 09:24:35 25 4
gpt4 key购买 nike

我有一个非常大的模型,有很多损失和指标。当我执行 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']

有没有办法给它们起更有意义的名字?

最佳答案

每个_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']

关于python - 有没有办法重命名 Keras 模型的指标和损失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53504813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com