关于TypeError: ‘numpy.ndarray‘ object is not callable报错
报错的代码:
import tensorflow as tf
import numpy as npdef sigmoid(x):return 1/(1+np.exp(-x))
def derivative(x):return sigmoid(x)(1-sigmoid(x))x=tf.constant([2.,1.,0.1])
out=derivative(x)
print(out)
修改后的代码:
import tensorflow as tf
import numpy as npdef sigmoid(x):return 1/(1+np.exp(-x))
def derivative(x):return sigmoid(x)*(1-sigmoid(x))x=tf.constant([2.,1.,0.1])
out=derivative(x)
print(out)
其实发现是sigmoid(x)和(1-sigmoid(x))之间少了一个“*”,网上也给出了很多关于这个错误的原因,但是这个还是得看自己的代码的具体原因,像我这个只是因为自己忘记加了 “ * ”报这样的错误,所以写代码的时候一定要注意一点。
关于TypeError: ‘numpy.ndarray‘ object is not callable报错相关推荐
- TypeError: 'numpy.ndarray' object is not callable
取ndarray的某几个数,若写为: a = np.array([0,1,2,3,4,5,6]) index = np.array([1,2,3]) b = a(index) print(b) 则会报 ...
- 【报错及解决】TypeError: ‘numpy.ndarray‘ object is not callable
一.错误代码及解决 def _shuffle_data(self):p = np.random.permutation(self._num_examples) #直接调用numoy的混排函数self. ...
- ‘numpy.float64‘ object is not callable
重点放最前面:检查函数名是否和变量名重复,或者被重新定义了. 我自己定义的一个函数如下. def rmspe(y, yhat):return np.sqrt(np.mean((yhat/y-1) ** ...
- Python 保存数组至.mat文件,报错:AttributeError: 'numpy.ndarray' object has no attribute 'items'
Python保存数组的方式有很多种,如savetxt,但这个函数只能保存一维或二维数组.为了保存高维数组,同时能够在matlab载入,可以使用scipy.io.savemat()函数,例子: impo ...
- AttributeError: 'numpy.ndarray' object has no attribute 'value_counts'
<python机器学习及实践>第二章第一个代码运行报错: AttributeError: 'numpy.ndarray' object has no attribute 'value_co ...
- TypeError: 'numpy.int64' object is not iterable ,'int' object is not iterable
想用一个list来动态地增加numpy类型数据,如下面的代码所示,发现报错TypeError: 'numpy.int64' object is not iterable a = [] b = np.a ...
- [转载] AttributeError: ‘numpy.ndarray‘ object has no attribute ‘insert‘的解决方法
参考链接: Python中的numpy.insert AttributeError: 'numpy.ndarray' object has no attribute 'insert' 代码: imp ...
- [转载] python 调用自己的方法报错,numpy.ndarray object has no attribute brighten
参考链接: Python中的numpy.eye 在使用python写美颜算法时,出现一个bug,AttributeError: 'numpy.ndarray' object has no attrib ...
- Yolov6解决常见报错(1)TypeError numpy.float64 object cannot be interpreted as an index
这几天偶然看见Yolov6出来,迫不及待的试了一下,结果看见网上评论说bug太多了,我作为使用者,想着积极做出贡献,把一些我解决的bug分享一下,方便大家也能看到顺便解决. 先看报错 Training ...
最新文章
- 年轻,误把unix当linux
- clion 工程打开选项 安全模式预览 Preview in Safe Mode 信任工程 Trust Project 简介
- pilt图像处理_Python用Pillow(PIL)进行简单的图像操作
- C++ :: 的用法小结
- wireshark数据包分析实战
- 发现程序美----while+for冒泡实现的
- “农业大数据”专题征文通知
- tomcat--because there was insufficient free space available after evicting expired cache entries
- HDU1198-----并查集
- java电子书很好的下载网站收藏
- 深入理解JVM虚拟机1:JVM内存的结构与消失的永久代
- 教你利用腾讯云cdn加速网站静态资源
- php培训班学多久,学php最快要多久? 学习路线?要不要报培训班?
- 第12集 关于库卡机器人对需要减速和插值方式说明
- ArrayList的扩容机制
- 【已解决】HHC6003: 错误: 文件 Itircl.dll 没有被正确注册。怎么办?
- 决策树算法实战之预测眼镜类型
- 公子世无双,代码永流传!!!我与github。
- 【Bioconductor系列】如何用Bioconductor对基因组注释
- 八股文--Java基础下