作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试开始学习一些机器学习并尝试导入 Tensorflow,但遇到了 ModuleNotFoundError:
ModuleNotFoundError: No module named 'tensorflow.python.ops.numpy_ops'
代码目前只是尝试导入包:
import os
import sys
import math
import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras import LSTM
完整的追溯是:
Traceback (most recent call last):
File "C:\Users\stacey\Documents\Atela\MachineLearning\NeuralNetworks\NeuralNetwork1.0.py", line 17, in <module>
from tensorflow.keras import LSTM
File "C:\Users\stacey\AppData\Roaming\Python\Python36\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\stacey\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\__init__.py", line 47, in <module>
from tensorflow.python import distribute
File "C:\Users\stacey\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\distribute\__init__.py", line 28, in <module>
from tensorflow.python.distribute.experimental import collective_all_reduce_strategy
File "C:\Users\stacey\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\distribute\experimental\__init__.py", line 25, in <module>
from tensorflow.python.distribute import tpu_strategy
File "C:\Users\stacey\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\distribute\tpu_strategy.py", line 28, in <module>
from tensorflow.compiler.xla.experimental.xla_sharding import xla_sharding
File "C:\Users\stacey\AppData\Roaming\Python\Python36\site-packages\tensorflow\compiler\xla\experimental\xla_sharding\xla_sharding.py", line 23, in <module>
from tensorflow.compiler.tf2xla.python import xla as tf2xla
File "C:\Users\stacey\AppData\Roaming\Python\Python36\site-packages\tensorflow\compiler\tf2xla\python\xla.py", line 43, in <module>
from tensorflow.python.ops.numpy_ops import np_utils
ModuleNotFoundError: No module named 'tensorflow.python.ops.numpy_ops'
Python 版本:3.6
Tensorflow 版本:2.6.2
最佳答案
我认为没有tensorflow.keras.LSTM
。也许您正在寻找 tensorflow.keras.layers.LSTM
?
更新:
问题已由 upgrading 解决到最新版本的 tensorflow (2.9.1) 和 python (3.9)。 Here可以找到版本兼容性表。
关于python - 模块未找到错误 : No module named 'tensorflow.python.ops.numpy_ops' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73413744/
我是一名优秀的程序员,十分优秀!