keras TypeError:VariableMetaclass._variable_v1_call()获取了意外的关键字参数“experimental_enable_variable_lifting”

ygya80vv  于 2023-03-23  发布在  其他
关注(0)|答案(1)|浏览(456)

我得到这个TypeError,同时从Tensorflow创建一个keras模型,在__init__方法中,一个自定义类,有什么想法吗?
我的代码:

self.model = keras.Sequential([
    keras.layers.Dense(1, input_dim=self.degree),
    keras.layers.Dense(1)
    ])
self.model.compile(optimizer=optimizer, loss=loss)
self.model.summary()

错误:

self.model = keras.Sequential([
                 ^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\tensorflow\python\trackable\base.py", line 205, in _method_wrapper
    result = method(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "C:\Python311\Lib\site-packages\tensorflow\python\ops\variables.py", line 285, in __call__
    return cls._variable_v1_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: VariableMetaclass._variable_v1_call() got an unexpected keyword argument 'experimental_enable_variable_lifting'

Tensorflow版本信息:

Name: tensorflow
Version: 2.12.0rc1
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: C:\Python311\Lib\site-packages
Requires: tensorflow-intel
Required-by:
ve7v8dk2

ve7v8dk21#

我也遇到了同样的问题。你试过安装keras 2.12.0rc1吗?我在这里试过(pip install keras==2.12.0rc1 --user),现在似乎可以工作了。

相关问题