2021
07-26
07-26
pytorch 如何实现HWC转CHW
看代码吧~importtorchimportnumpyasnpfromtorchvision.transformsimportToTensort=torch.tensor(np.arange(24).reshape(2,4,3))print(t)#HWC转CHWprint(t.transpose(0,2).transpose(1,2))print(t.permute(2,0,1))print(ToTensor()(t.numpy()))D:\anaconda\python.exeC:/Users/liuxinyu/Desktop/pytorch_test/day3/hwc转chw.pytensor([[[0,1,2],[3,4,5],[6,7,8],[9,10,11]],[[12,13,14],[15,16,17],...
继续阅读 >