更新旧版Keras模型时出现不推荐警告

2024-04-18 22:09:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个旧的Keras模型文件,它工作得很好。但是,当我试图在tensorflow==1.13.1中加载它时,会收到大量警告:

import tensorflow as tf
model = tf.keras.models.load_model("best.h5")

WARNING:tensorflow:From .pyenv/versions/3.6.0/lib/python3.6/site-packages/tensorflow/python/ops/resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version. Instructions for updating: Colocations handled automatically by placer.

WARNING:tensorflow:From .pyenv/versions/3.6.0/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead.

假设我不想重新训练模型,如何更新它以避免出现这些错误?如果需要,原始网络(简单的1D covnet)如下:

^{pr2}$

Tags: frompy模型pyenvmodelislibpackages
1条回答
网友
1楼 · 发布于 2024-04-18 22:09:25

这些不是错误,它们与tensorflow中的内部Keras实现有关,除了等待tf.keras更新它们的实现和不使用已弃用的函数之外,没有什么可以做的。在

相关问题 更多 >