Oct-19-2018, 08:33 AM
(This post was last modified: Oct-19-2018, 08:34 AM by Santhosh198915.)
I have no idea how to resolve this issue, please help
I'm getting this error
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#[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 x |
1 2 3 4 5 6 7 8 |
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' |