我认为输出应该是 x.shape=[2,4,3], y.shape=[2,1,3]. 但是实际输出是 x.shape=[2,4,3], y.shape=[2,3]
请教大家,y的第二个维度怎么没有了?谢谢
import numpy as np
a = np.random.rand(2,5,3)
print(a)
x = a[:,:-1,:]
y = a[:,-1,:]
print(x.shape)
print(y.shape)
第5行改为y = a[:,4:5,:] 试试。
修改如下:
import numpy as np
a = np.random.rand(2,5,3)
print(a)
x = a[:,:-1,:]
# https://blog.csdn.net/qiqicos/article/details/78971406
# https://www.zhihu.com/question/345304257/answer/2925317518
# https://blog.csdn.net/zgcr654321/article/details/88015849
y = a[:,4:5,:]
print(x.shape)
print(y.shape)
print(x)
print(y)