1. python中有一个zfill方法用来给字符串前面补0,非常有用
astr = str(a) # a is a int
i = int(astr)
3. Tensor, numpy的array之间的转换
b = a.numpy() #a为tensor
b = torch.from_numpy(a) #a为numpy的array
参考:https://www.jianshu.com/p/5ae644748f21
1. python中有一个zfill方法用来给字符串前面补0,非常有用
astr = str(a) # a is a int
i = int(astr)
3. Tensor, numpy的array之间的转换
b = a.numpy() #a为tensor
b = torch.from_numpy(a) #a为numpy的array
参考:https://www.jianshu.com/p/5ae644748f21