# AttributeError: 'ConvNet' object has no attribute 'conv1'

**URL:** <https://discuss.pytorch.org/t/attributeerror-convnet-object-has-no-attribute-conv1/172441>\
**Category:** vision\
**Created:** [February 13, 2023, 5:13am UTC](https://discuss.pytorch.org/t/attributeerror-convnet-object-has-no-attribute-conv1/172441 "2023-02-13T05:13:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacky1](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jacky1/32/57275_2.png) [@Jacky1](https://discuss.pytorch.org/u/Jacky1)\
**Post date:** [February 13, 2023, 5:13am UTC](https://discuss.pytorch.org/t/attributeerror-convnet-object-has-no-attribute-conv1/172441/1 "2023-02-13T05:13:18Z")

</div>

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.

```auto

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

```auto
~\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'

```

---

<div class="post-metadata">

**Author:** ![khushi-411](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/khushi-411/32/51391_2.png) [@khushi-411](https://discuss.pytorch.org/u/khushi-411)\
**Post date:** [February 13, 2023, 5:19am UTC](https://discuss.pytorch.org/t/attributeerror-convnet-object-has-no-attribute-conv1/172441/2 "2023-02-13T05:19:07Z")

</div>

Hey, there!  
In the ` __init__ ` class, you have called using `self.convl` instead of `self.conv1`. Seems like a minor typo. Thanks!
