导入tensorflow_hub时为什么会发生属性错误?

时间:2020-03-05 15:51:31

标签: python tensorflow

from __future__ import absolute_import, division, print_function, unicode_literals

import numpy as np

import tensorflow as tf

import tensorflow_hub as hub
import tensorflow_datasets as tfds

我正在关注tensorflow,但是当我尝试导入tensorflow_hub时,会发生类似错误

Traceback (most recent call last):
  File "C:/PythonProjects/191217_TensorFlow_Project/model3.py", line 7, in <module>
    import tensorflow_hub as hub
  File "C:\Users\UserK\Anaconda3\envs\191217_TensorFlow_Project_1\lib\site-packages\tensorflow_hub\__init__.py", line 53, in <module>
    from tensorflow_hub.keras_layer import KerasLayer
  File "C:\Users\UserK\Anaconda3\envs\191217_TensorFlow_Project_1\lib\site-packages\tensorflow_hub\keras_layer.py", line 39, in <module>
    class KerasLayer(tf.keras.layers.Layer):
AttributeError: 'function' object has no attribute 'layers'

我没有任何名为'tensorflow_hub.py'的文件,所以我不知道为什么会发生。

0 个答案:

没有答案