tuple index out of range
生活随笔
收集整理的這篇文章主要介紹了
tuple index out of range
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
self.X = tf.placeholder(dtype=tf.int32,shape=[None,train_X.shape[1]],name="input_x")
提示出現(xiàn)錯(cuò)誤:
tuple index out of range
?
?而我立馬判斷為train_X數(shù)據(jù)類型為tuple,然后再去苦苦尋找;在錯(cuò)誤的方向上浪費(fèi)時(shí)間;非常不注重在方向判斷上努力;
戰(zhàn)略上極其懶惰。
x = np.array([1,2]) print(x) print(x.shape) print(x.shape[1])IndexError Traceback (most recent call last) <ipython-input-64-96f6a35db83b> in <module>2 print(x)3 print(x.shape) ----> 4 print(x.shape[1])IndexError: tuple index out of range如果數(shù)據(jù)的shape是一維的,那么shape的長(zhǎng)度只有1,所以shape[1]就溢出了。
總結(jié)
以上是生活随笔為你收集整理的tuple index out of range的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 三维列表转换成数组时,维度却只有二维
- 下一篇: sklearn one_hot向量输出维