1.RuntimeError: freeze_support()
参考:https://github.com/pytorch/pytorch/issues/5858
加上:
if __name__ == '__main__':
2.log_p = F.log_softmax(input, dim=1)
pytorch的0.2版本不需要加维度,而>=0.3必须要加上维度
3.
UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
修改:if np.isnan(float(loss.item())):#loss.data[0]
4.
kwargs = {'num_workers': 0, 'pin_memory': True} if cuda else {}
其中num_workers>0的值都会出现如下错误:
BrokenPipeError: [Errno 32] Broken pipe
其中可能是使用多线程的原因,与windows平台有关
On a Windows machine, you may need to wrap your multiprocessing code inside:
if __name__ == '__main__'
https://github.com/pytorch/pytorch/issues/494#issuecomment-304439658