注意事項(xiàng)
函數(shù)的默認(rèn)參數(shù)如果不是tensor的話,需要指定類型
list中元素默認(rèn)為tensor饺藤,如果不是塔淤,也要指定類型
常見(jiàn)報(bào)錯(cuò)
ValueError: substring not found
forward函數(shù)中不允許出現(xiàn)中文注釋
Module is not iterable(大概是這樣的錯(cuò)誤)
不支持模型遍歷及對(duì)模型取下標(biāo)的操作
torch.jit.frontend.UnsupportedNodeError: Dict aren’t supported
forward 函數(shù)里初始化字典,由 a={} 改成 a=dict()斥杜,不過(guò)dict類型盡量不要在forward中使用虱颗,容易出錯(cuò)
torch.jit.frontend.UnsupportedNodeError: continue statements aren’t supported
不支持continue
torch.jit.frontend.UnsupportedNodeError: try blocks aren’t supported
不支持try-except
Unknown builtin op: aten::Tensor
不能使用torch.Tensor(),如果是把python中的int蔗喂,float等類型轉(zhuǎn)成tensor可以使用torch.tensor()
如果是張量拼接盡量使用torch.cat