无法将输入数组从形状(5,10)广播到形状(3,10)

时间:2018-11-26 12:12:15

标签: ipython

通过执行代码(见下文),我有以下输出错误。 无法将形状(5,10)的输入数组广播到形状(3,10)

import numpy as np
n_a = 3
n_x = 5
concat = np.random.randn(8,10)
concat[: n_a, :] = a_prev
concat[n_a :, :] = xt

print("concat :=" +str(concat))
print("a_prev :=" +str(a_prev))
print("xt :=" + str(xt))

完全错误之后:

ValueError                                Traceback (most recent call last)
<ipython-input-27-7519fa3a400a> in <module>()
      3 n_x = 5
      4 concat = np.random.randn(8,10)
----> 5 concat[: n_a, :] = a_prev
      6 concat[n_a :, :] = xt
      7 

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

0 个答案:

没有答案