{AttributeError:模块'tensorflow_core._api.v2.config'没有属性'experimental_list_devices'}我如何解决此错误?
问题内容:
我在Windows 10上使用tensorflow 2.1。在跑步
model.add(Conv3D(16, (22, 5, 5), strides=(1, 2, 2), padding='valid',activation='relu',data_format= "channels_first", input_shape=input_shape))
在spyder上,我得到了上面的错误。我该如何解决这个错误?
问题答案:
我在这里找到了答案-https: //github.com/keras-
team/keras/issues/13684
。我load_model()
在Anaconda的keras遇到了同样的问题:
AttributeError:模块“ tensorflow_core._api.v2.config”没有属性“
experimental_list_devices”
我发现问题的根源
… \ anaconda3 \ envs \ tf_env \ Lib \ site-packages \ keras \ backend \
tensorflow_backend.py
在第506行中,我更改了行
_LOCAL_DEVICES = tf.config.experimental_list_devices()
至
devices = tf.config.list_logical_devices()
_LOCAL_DEVICES = [x.name for x in devices]
而且有效