Tensorflow Keras ProgbarLogger 不接受参数

问题描述 投票:0回答:1

在 Python 3.10.14 和 TensorFlow 版本 2.16.1 中,以下最小工作示例会产生错误:

import tensorflow as tf
pb = tf.keras.callbacks.ProgbarLogger(count_mode='steps')

错误是:

TypeError: ProgbarLogger.__init__() got an unexpected keyword argument 'count_mode'

但是 ProgbarLogger 的文档也在这里)说这个论点存在。为了检查是否是拼写错误,我还尝试了位置参数版本:

import tensorflow as tf
pb = tf.keras.callbacks.ProgbarLogger('steps')

还出现错误:

TypeError: ProgbarLogger.__init__() takes 1 positional argument but 2 were given

这是张量流的最新版本,如果我没有以某种方式弄乱安装命令,所以我不确定这里出了什么问题。无论如何,在我上面链接的第二个文档页面中,版本号与我的相同(我通过运行

pip show tensorflow
获得)。

可能相关的告诉你,打开python后,显示如下信息:

Python 3.10.14 | packaged by Anaconda, Inc. | (main, Mar 21 2024, 16:20:14) [MSC v.1916 64 bit (AMD64)] on win32

运行

import tensorflow as tf
后,它会打印:

2024-04-08 10:38:02.032301: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-04-08 10:38:21.403223: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.

最后一点,所有这些都是从 VS 代码中运行的,但我认为这不相关。

python tensorflow keras
1个回答
0
投票

将tensorflow降级到版本2.15.0为我解决了这个问题。

pip install tensorflow==2.15.0
© www.soinside.com 2019 - 2024. All rights reserved.