【debug】ValueError: all the input arrays must have same number of dimensions 解決
阿新 • • 發佈:2021-02-15
使用
# T是個整數tensor
np.concatenate((align[1:],T.cpu().numpy()), axis=0)
報錯ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 0 dimension(s)
檢視align[1:]及T.cpu().numpy()的shape如下:
T.cpu().numpy()少了一維。更改如下
np.concatenate((align[1:],[T.cpu().numpy()]), axis=0)
#或
np.concatenate((align[1:],T.cpu().numpy().reshape(-1)), axis=0)