[英]ModuleNotFoundError: No module named 'tensorflow.python.ops.numpy_ops'
我正在嘗試開始學習一些機器學習並嘗試導入 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
完整的追溯是:
回溯(最近一次通話最后):
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
?
更新:
該問題已通過升級到最新版本 tensorflow (2.9.1) 和 python (3.9) 得到解決。 在這里可以找到版本兼容性表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.