gpt4 book ai didi

python - Numpy append 不允许串联

转载 作者:太空宇宙 更新时间:2023-11-04 11:06:52 29 4
gpt4 key购买 nike

<分区>

这里还有很多类似的问题,最好的问题之一可能是:numpy array concatenate: "ValueError: all the input arrays must have same number of dimensions"

我的函数 numpy.append 卡住了。在这里您可以找到 docs .

我的两个数组是:

X_p3 = np.array([[1,2], [3,4], [3,3]])
y_3 = np.array([[1], [1],[1]])

enter image description here

具有形状:X_p3 (3,2)y_3 (3,1)

如果我运行:np.append(X_p3, y_3, axis=0)

我收到错误:

ValueError: all the input array dimensions except for the concatenation axis must match exactly

我已经尝试过:np.append(X_p3, y_3.reshape(len(y_3), 2), axis=0) ,但这也给出了另一个错误。我该如何解决这个问题?

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com