@@ -35,11 +35,13 @@ def _test_fprop(self, state_below):
3535
3636
3737class VGG16 (BaseModel ):
38- '''
39- REFERENCE: Very Deep Convolutional Networks for Large-Scale Image Recognition
40- (https://arxiv.org/abs/1409.1556)
41- '''
38+
39+ @BaseModel .init_name_scope
4240 def __init__ (self , input_channels , input_shape ):
41+ '''
42+ REFERENCE: Very Deep Convolutional Networks for Large-Scale Image Recognition
43+ (https://arxiv.org/abs/1409.1556)
44+ '''
4345 layers = []
4446 # block 1
4547 layers .append (Conv2D (input_channels , num_filters = 64 , kernel_size = (3 ,3 ), stride = (1 ,1 ), padding = 'SAME' ))
@@ -123,11 +125,13 @@ def __init__(self, input_channels, input_shape):
123125
124126
125127class VGG19 (BaseModel ):
126- '''
127- REFERENCE: Very Deep Convolutional Networks for Large-Scale Image Recognition
128- (https://arxiv.org/abs/1409.1556)
129- '''
128+
129+ @BaseModel .init_name_scope
130130 def __init__ (self , input_channels , input_shape ):
131+ '''
132+ REFERENCE: Very Deep Convolutional Networks for Large-Scale Image Recognition
133+ (https://arxiv.org/abs/1409.1556)
134+ '''
131135 layers = []
132136 # block 1
133137 layers .append (Conv2D (input_channels , num_filters = 64 , kernel_size = (3 ,3 ), stride = (1 ,1 ), padding = 'SAME' ))
@@ -223,12 +227,13 @@ def __init__(self, input_channels, input_shape):
223227
224228
225229class ResNetBase (BaseModel ):
226- '''
227- REFERENCE: Deep Residual Learning for Image Recognition (https://arxiv.org/abs/1512.03385)
228- '''
229230
231+ @BaseModel .init_name_scope
230232 def __init__ (self , input_channels , input_shape , config ):
231- '''config (list of ints): a list of 4 number of layers for each identity block
233+ '''
234+ REFERENCE: Deep Residual Learning for Image Recognition (https://arxiv.org/abs/1512.03385)
235+ PARAMS:
236+ config (list of ints): a list of 4 number of layers for each identity block
232237 '''
233238
234239 layers = []
@@ -276,12 +281,13 @@ def __init__(self, input_channels, input_shape, config):
276281
277282
278283class ResNetSmall (ResNetBase ):
279- '''
280- REFERENCE: Deep Residual Learning for Image Recognition (https://arxiv.org/abs/1512.03385)
281- '''
282284
285+ @ResNetBase .init_name_scope
283286 def __init__ (self , input_channels , input_shape , config ):
284- '''config (list of ints): a list of 2 number of layers for each identity block
287+ '''
288+ REFERENCE: Deep Residual Learning for Image Recognition (https://arxiv.org/abs/1512.03385)
289+ PARAMS:
290+ config (list of ints): a list of 2 number of layers for each identity block
285291 '''
286292 layers = []
287293 layers .append (Conv2D (input_channels , num_filters = 64 , kernel_size = (7 ,7 ), stride = (2 ,2 ), padding = 'SAME' ))
@@ -329,10 +335,8 @@ def __init__(self, input_channels, input_shape):
329335
330336
331337class ShortCutBlock (BaseModel ):
332- '''
333- REFERENCE: Deep Residual Learning for Image Recognition (https://arxiv.org/abs/1512.03385)
334- '''
335338
339+ @BaseModel .init_name_scope
336340 def __init__ (self , input_channels , input_shape , filters , kernel_size , stride ):
337341 '''
338342 DESCRIPTION:
@@ -377,6 +381,8 @@ def __init__(self, input_channels, input_shape, filters, kernel_size, stride):
377381
378382
379383class IdentityBlock (BaseModel ):
384+
385+ @BaseModel .init_name_scope
380386 def __init__ (self , input_channels , input_shape , nlayers = 2 , filters = [32 , 64 ]):
381387 '''
382388 DESCRIPTION:
@@ -421,6 +427,7 @@ def identity_layer(in_hn, shape):
421427
422428class DenseBlock (BaseModel ):
423429
430+ @BaseModel .init_name_scope
424431 def __init__ (self , input_channels , input_shape , growth_rate , nlayers ):
425432 '''
426433 DESCRIPTION:
@@ -455,10 +462,11 @@ def _conv_layer(in_hn, shape, in_channel):
455462
456463class TransitionLayer (BaseModel ):
457464
465+ @BaseModel .init_name_scope
458466 def __init__ (self , input_channels , input_shape ):
459467 '''
460468 DESCRIPTION:
461- The transition layer of dense net (Densely Connected Convolutional Networks https://arxiv.org/abs/1608.06993)
469+ The transition layer of densenet (Densely Connected Convolutional Networks https://arxiv.org/abs/1608.06993)
462470 '''
463471 layers = []
464472 layers .append (Conv2D (input_channels , num_filters = input_channels , kernel_size = (1 ,1 ), stride = (1 ,1 ), padding = 'SAME' ))
@@ -475,11 +483,11 @@ def __init__(self, input_channels, input_shape):
475483
476484
477485class DenseNet (BaseModel ):
478- '''
479- REFERENCE: Densely Connected Convolutional Networks (https://arxiv.org/abs/1608.06993)
480- '''
486+
487+ @BaseModel .init_name_scope
481488 def __init__ (self , input_channels , input_shape , ndense = 3 , growth_rate = 12 , nlayer1blk = 12 ):
482489 '''
490+ REFERENCE: Densely Connected Convolutional Networks (https://arxiv.org/abs/1608.06993)
483491 PARAMS:
484492 ndense (int): number of dense blocks
485493 nlayer1blk (int): number of layers in one block, one layer refers to
@@ -504,7 +512,7 @@ def __init__(self, input_channels, input_shape, ndense=3, growth_rate=12, nlayer
504512
505513 dense = DenseBlock (transit .output_channels , transit .output_shape , growth_rate , nlayer1blk )
506514 layers .append (dense )
507- layers .append (AvgPooling (poolsize = dense .output_shape , stride = (1 ,1 ), padding = 'VALID' ))
515+ # layers.append(AvgPooling(poolsize=dense.output_shape, stride=(1,1), padding='VALID'))
508516
509517 assert np .prod (dense .output_shape ) > 0 , 'output shape {} is <= 0' .format (dense .output_shape )
510518 self .startnode = StartNode (input_vars = [None ])
@@ -529,6 +537,8 @@ def __init__(self, input_channels, input_shape, ndense=3, growth_rate=12, nlayer
529537
530538
531539class UNet (BaseModel ):
540+
541+ @BaseModel .init_name_scope
532542 def __init__ (self , input_channels , input_shape ):
533543
534544 def _encode_block (in_hn , shape , in_ch , out_ch ):
0 commit comments