数组在python中不可调用“'numpy.ndarray'对象不可调用"; [英] array is not callable in python "'numpy.ndarray' object is not callable"

查看:136
本文介绍了数组在python中不可调用“'numpy.ndarray'对象不可调用";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个神经网络,当我尝试对两个 numpy.ndarray 进行混洗时出现此错误.我尝试重新检查 shuffle 函数格式,但找不到任何错误.请帮忙

I am working on a neural network and when i try to shuffle the two numpy.ndarray i get this error. I tried rechecking the shuffle function format and cannot find any faults with that. Please help

train_images,train_labels = shuffle(train_images,train_labels)
TypeError                                 
Traceback (most recent call last)
<ipython-input-8-b3f4173331ac> in <module>
 18     print("Training the Network")
 19     for i in range(epoch):
 20     --> train_images,train_labels = shuffle(train_images,train_labels)
 21         for offset in range (0,no_eg,batch_size):
 22             end = offset+batch_size

/usr/lib/python3.5/random.py in shuffle(self, x, random)
275             for i in reversed(range(1, len(x))):
276                 # pick an element in x[:i+1] with which to exchange x[i]
277            -->  j = _int(random() * (i+1))
278                 x[i], x[j] = x[j], x[i]
279 

TypeError: 'numpy.ndarray' object is not callabl

谢谢

推荐答案

查看 random.shuffle(x[, random])

可选参数 random 是一个 0 参数函数,返回一个在 [0.0, 1.0) 中随机浮动;默认情况下,这是函数 random()

The optional argument random is a 0-argument function returning a random float in [0.0, 1.0); by default, this is the function random()

在您的情况下,您通过了 train_labels,根据错误消息,它是 numpy.ndarray,而不是函数

in your case you pass train_labels, which, according to error message is numpy.ndarray, not function

这篇关于数组在python中不可调用“'numpy.ndarray'对象不可调用";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆