打乱数据报错: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]


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM