Python 如何修复 AttributeError:模块 'numpy' 没有属性 'square'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48235169/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:37:00  来源:igfitidea点击:

How to fix AttributeError: module 'numpy' has no attribute 'square'

pythonpython-3.xnumpykerasattributeerror

提问by Hoda Fakharzadeh

I have updated numpy to 1.14.0. I use Windows 10. I tried to run my code and I got this error:

我已将 numpy 更新到 1.14.0。我使用 Windows 10。我尝试运行我的代码,但出现此错误:

AttributeError: module 'numpy' has no attribute 'square'

AttributeError: 模块 'numpy' 没有属性 'square'

Here are my imports:

这是我的进口:

%matplotlib inline
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
from sklearn.metrics import confusion_matrix
import math

采纳答案by Hoda Fakharzadeh

I removed numpy.py then updated my numpy and it worked!

我删除了 numpy.py 然后更新了我的 numpy 并且它起作用了!