打乱数据报错:only integer scalar arrays can be converted to a scalar index


batch_x=[1,2,3,4,5,6,7,8,9]
indices = np.random.permutation(len(batch_x))
batch_x = batch_x[indices]
发生错误:TypeError:only integer scalar arrays can be converted to a scalar index

修改为:


indices = np.random.permutation(np.arange(len(batch_x)))
batch_x = np.array(batch_x)[indices]
batch_y = np.array(batch_y)[indices]
batch_label = np.array(batch_label)[indices]
posted @ 2020-06-08 17:20  liangxinxin  阅读(4338)  评论(0编辑  收藏  举报