'torch.nn' has no attribute 'SiLU'
解决方法:
pip install pytorch torchvision -U
临时解决方法:
把torch.nn.SiLU()改为SiLU()
SiLU() 代码如下:
class SiLU(torch.nn.Module): # export-friendly version of nn.SiLU()
@staticmethod
def forward(x):
return x * torch.sigmoid(x)
这一版没测过:
class SiLU(torch.nn.Module):
"""
[https://arxiv.org/pdf/1710.05941.pdf]
"""
def __init__(self, inplace: bool = False):
super().__init__()
self.inplace = inplace
def forward(self, x):
return x.mul_(x.sigmoid()) if self.inplace else x.mul(x.sigmoid())