python - IndexError:索引 2048 超出轴 1 的范围,大小为 2
问题描述
我下面的代码给了我以下错误
"IndexError: index 2048 is out of bounds for axis 1 with size 2".
我很新,所以我不知道如何解决这个问题。
任何形式的帮助将不胜感激。
X=[]
X1 = np.load('class_1data_model1.npy')
X2 = np.load('class_2data_model1.npy')
X_data = np.append(X1,X2,axis=0)
Y_data = X_data[0:,2048]
X_data = X_data[:,0:2048]
x_tr,x_ts,y_tr,y_ts = train_test_split(X_data, Y_data, test_size=0.2,random_state=10
解决方案
尝试这个。
X1 = np.load('class_1data_model1.npy')
X2 = np.load('class_2data_model1.npy')
X_data = np.append(X1,X2,axis=0)
nrows, nclos = X_data.shape
Y_data = X_data[:,2048].reshape((nrows,1))
X_data = X_data[:,:2048]
print('X_data.shape: \t{} (OLD)'.format((nrows,ncols))
print('X_data.shape: \t{} (NEW)'.format(X_data.shape)
print('Y_data.shape: \t{}'.format(Y_data.shape)
### Now perform train_test_split.
推荐阅读
- google-sheets - “冻结”谷歌表格列值
- python - 使用 apply 更新 Dataframe 中的行不起作用
- c# - Unity 播放器的射击功能将不起作用
- javascript - 如何在javascript代码中执行另一个nodejs?
- azure - 尝试将数据库从弹性池复制到我的另一个 Azure 服务器时出错
- vim - 有没有办法改变快速修复列表的显示模式
- prebid.js - 由 appnexus 托管的预投标服务器放大器配置
- c++ - 未调用 NodeJS 嵌套函数的 C++ 插件
- html - 我想更改标签:检查输入复选框后的颜色
- javascript - 无法在“节点”上执行“removeChild”:参数 1 不是“节点”类型。移除元素的方法