Oct-19-2018, 10:12 AM
(Oct-19-2018, 08:33 AM)Santhosh198915 Wrote: I have no idea how to resolve this issue, please help
#[Convolution] -> [Batch Normalization] -> [ReLU] def Conv_block2d(in_channels,out_channels,*args,**kwargs): return nn.Sequential(nn.Conv2d(in_channels,out_channels,*args,**kwargs,bias=False),nn.BatchNorm2d(out_channels,eps=0.001),nn.ReLU(inplace=True)) class MainBlock(nn.Module): """docstring for MainBlock"nn.Module""" def __init__(self): super(MainBlock,self).__init__() self.pool_2x2 = nn.MaxPool2d(2,2) """ size = [3,18,36,7,5] for in_c,out_c,k in zip(size[:2],size[1:3],size[3:]): print("in channel",in_c,"out channel",out_c,"kernel size",k) in channel 3 out channel 18 kernel size 7 (256x256x3) * (7x7x18) = (250x250x18))*(2x2x1) = (125x125x18) in channel 18 out channel 36 kernel size 5 (125x125x18 * (5x5x36) = (125x125x36))*(2x2x1) = (60x60x36) """ self.block1_size = [3,18,36,7,5] block1_out = [self.pool_2x2(Conv_block2d(in_c,out_c,kernel_size=k)) for in_c,out_c,k in zip(self.block1_out[:2],self.block1_out[1:3],self.block1_out[3:])] self.block1_output = nn.Sequential(*block1_out) def forward(self,x): #Block 1 output (60x60x36) x = self.block1_output(x) return xI'm getting this error
Traceback (most recent call last): File "simpletest.py", line 170, in <module> net = MainBlock().cuda() File "simpletest.py", line 83, in __init__ self.block1_out = [self.pool_2x2(Conv_block2d(in_c,out_c,kernel_size=k)) for in_c,out_c,k in zip(self.block1_out[:2],self.block1_out[1:3],self.block1_out[3:])] File "/home/ffffff/.virtualenvs/LearnPytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 518, in __getattr__ type(self).__name__, name)) AttributeError: 'MainBlock' object has no attribute 'block1_out'
(Oct-19-2018, 09:11 AM)volcano63 Wrote:(Oct-19-2018, 08:59 AM)Santhosh198915 Wrote: Even with proper Indentation i am getting the same error
Line 23 - could you guess what you missed there?
Built this using this soruce https://towardsdatascience.com/pytorch-h...54597b5f17