I was trying to learn HiddenLayer visualization, but there was an error in the title when the code was running properly, and I found that my code seemed to be fine.
class ConvNet(nn.Module):
def __init__(self):
super(ConvNet,self).__init__()
self.convl=nn.Sequential(
nn.Conv2d(
in_channels=1,
out_channels=16,
kernel_size=3,
stride=1,
padding=1,
),
nn.ReLU(),
nn.AvgPool2d(
kernel_size=2,
stride=2,
),
)
self.conv2=nn.Sequential(
nn.Conv2d(16,32,3,1,1),
nn.ReLU(),
nn.MaxPool2d(2,2)
)
self.fc=nn.Sequential(
nn.Linear(
in_features=32*7*7,
out_features=128,
),
nn.ReLU(),
nn.Linear(128,64),
nn.ReLU()
)
self.out=nn.Linear(64,10)
def forward(self,x):
x=self.conv1(x)
x=self.conv2(x)
x=x.view(x.size(0),-1)
x=self.fc(x)
output=self.out(x)
return output
Myconvnet=ConvNet()
import hiddenlayer as hl
hl_graph=hl.build_graph(Myconvnet,torch.zeros([1,1,28,28]))
hl_graph.theme=hl.graph.THEMES["blue"].copy()
hl_graph.save("./deep_learning_data/MyConvnet_h1.png",format="png")
then
~\anaconda3\lib\site-packages\torch\nn\modules\module.py in __getattr__(self, name)
1206 return modules[name]
1207 raise AttributeError("'{}' object has no attribute '{}'".format(
-> 1208 type(self).__name__, name))
1209
1210 def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:
AttributeError: 'ConvNet' object has no attribute 'conv1'