这段代码有什么问题?我不能简单地将 的第一列切片data并将其分配给 X 吗?
import numpy as np
data =np.array([[5.2, -1.5], [-4.1, 3], [-12.3, 55]])
print(data)
X = data[:,0]
print('shape of X ', X.shape)
print('X.shape[0] ',X.shape[0])
print('X.shape[1] ',X.shape[1])
它抛出以下消息:
shape of X (3,)
X.shape[0] 3
Traceback (most recent call last):
File "shape.py", line 7, in <module>
print('X.shape[1] ',X.shape[1])
IndexError: tuple index out of range
烙印99
慕妹3146593
相关分类