运行程序时出现两种报错
报错:
cannot import name 'Optional' from 'torch.jit.annotations'
cannot import name 'Optional' from 'torch.jit.annotations'
这种情况是pytorch和torchvision版本问题
安装正确且对应的版本即可,不需要卸载旧版本,安装指令可自动卸载。
pip install torch==1.4.0+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html
版本对应关系参考:
https://github.com/pytorch/vision
安装指令参考官网:
https://pytorch.org/get-started/previous-versions/