python二维数据读取对齐_[Python ] Python 多维数组转换的维度对齐问题

本文通过示例介绍了Python中遇到的多维数组转换时的维度对齐错误,强调了在将多个多维数组组合成列表时,最后一维必须保持一致的重要性。错误示例展示了不同形状和类型的输入数组导致的广播错误。
摘要由CSDN通过智能技术生成

标签:

转载自https://stackoverflow.com/questions/48373228/valueerror-could-not-broadcast-input-array-from-shape-25-1-into-shape-25

通过几个例子简单了解一下:

Here’s an example of the error:

>>> a = [np.zeros((224,224,3)), np.zeros((224,224,3)), np.zeros((224,224))]

>>> np.array(a)

ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)

or, different type of input, but the same error:

>>> a = [np.zeros((224,224,3)), np.zeros((224,224,3)), np.zeros((224,224,13))]

>>> np.array(a)

Traceback (most recent call last):

File "", line 1, in

ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)

Alternatively, similar but with a different error message:

>>> a = [np.zeros((224,224,3)), np.zeros((224,224,3)), np.zero

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值