gpt4 book ai didi

python - 模块未找到错误 : No module named 'tensorflow.python.ops.numpy_ops'

转载 作者:行者123 更新时间:2023-12-05 03:19:38 25 4
gpt4 key购买 nike

我正在尝试开始学习一些机器学习并尝试导入 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com