[英]How to use "load_model" in Keras after trained using as metric "tf.keras.metrics.AUC"?
After training using that metric on my model.fit()
.在我的model.fit()
上使用该指标进行训练后。 When I try to load the model using "load_model".当我尝试使用“load_model”加载 model 时。 It don't recognize the metric AUC, so I add it on custom_objects={"auc":AUC}
.它无法识别度量 AUC,因此我将其添加到custom_objects={"auc":AUC}
。
I get this error:我收到此错误:
ValueError: Unknown metric function: {'class_name': 'AUC'... returning all the thresholds used and more information about the metric. ValueError: Unknown metric function: {'class_name': 'AUC'... 返回所有使用的阈值以及有关该指标的更多信息。
The code:编码:
model.compile(..., metrics=["accuracy", AUC(name="auc", curve="PR")]
load_model(checkpoint, custom_objects={"auc":AUC(name="auc")})
I already answered.我已经回答了。 When you have no defined metrics, you can load the model without compile it.当您没有定义的指标时,您可以加载 model 而无需编译它。 But adding the custom_objects like this:但是像这样添加custom_objects:
he code:他代码:
model.compile(..., metrics=["accuracy", AUC(name="auc", curve="PR")] load_model(checkpoint, custom_objects={"auc":AUC(name="auc")}, compile=False) model.compile(..., metrics=["accuracy", AUC(name="auc", curve="PR")] load_model(checkpoint, custom_objects={"auc":AUC(name="auc")} ,编译=假)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.