定义图卷积操作类时 AttributeError: module ‘torch’ has no attribute ‘Module’
错误提示
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[16], line 5
2 def mish(x):#Mish激活函数
3 return x * (torch.tanh(F.softplus(x)))
----> 5 class GraphConvolution(nn.Module):
6 def _init_(self,f_in,f_out,use_bias=True,activation=mish):
7 super()._init_()
AttributeError: module 'torch' has no attribute 'Module'
解决方法:
import torch as nn 改成from torch import nn
#引入深度学习框架库
import torch
import torch as nn
import torch.nn.functional as F
改完:
#引入深度学习框架库
import torch
from torch import nn
import torch.nn.functional as F