Torch.Tensor —classmix网络某个代码点测试, 半监督
import torch
A = torch.tensor([[[104.0070]],
[[116.6688]],
[[122.6789]]])
#(3,1,1)
print('--------this is the first output')
print(A[:,:,-1])
'''
tensor([[104.0070],
[116.6688],
[122.6789]])
'''
print('--------this is the second output')
print(A[:,:,:-1])
'''
tensor([], size=(3, 1, 0))
'''
#A[:,:,::-1] BUG:::: ValueError: negative step not yet supported
B = torch.tensor([[104.0070],
[116.6688],
[122.6789]])
#namely, B=A[:,:,-1]
print(B[:,-1]) #tensor([104.0070, 116.6688, 122.6789])
a = [1,2,3,4]
print(a[:-1])
#[1, 2, 3]
print(a[::-1])
#[4, 3, 2, 1]
import numpy as np
b = np.array([[1,2,3,4,5],[6,7,8,9,10]])
print(b[:,0]) #[1 6]
'''
第一个:,代表第一个维度,第二个0表示取第二维的所有0位数据
'''