秉承一贯风格:先挖坑:
优先级:
1. doc文档总结。(以及附加和torch的对比,写在最后)
2. 对Variable,Parameter以及自动反向传播的更深理解
3. 自定义反向传播的写法,以及注意点。包括扩展torch.autograd.Function以及torch.nn.Module
4. Variable的一些注意事项
5. 自定义loss函数
6. 将论坛中的一些常见问题进行总结。
附加:
# 可以将output中所有大于0.5的值都置为1,其余的置为0
# 返回的是 ByteTensor
output = (output > 0.5).mul_(1)
图像与tensor的相互转换
from PIL import Image
from torchvision.transforms import ToTensor, ToPILImage
def load_img(filepath):
img = ToTensor()(Image.open(filepath).convert('RGB'))
return img
def save_img(img, filepath):
ToPILImage()(img).save(filepath)