【发布时间】:2021-09-25 12:38:58
【问题描述】:
我使用 np.random.choice 获取随机索引但遇到以下错误。
TypeError:只有整数标量数组可以转换为标量索引。任何建议将不胜感激。
x_train = [0,1,2,3,4]
train_size = 4
batch_size =3
batch_mask = np.random.choice(train_size, batch_size)
print(batch_mask)
x_batch = x_train[batch_mask]
print(x_batch)
【问题讨论】:
标签: python