@@ -686,25 +686,17 @@ def calc_parameter_dims(self, input_size, output_size):
686
686
687
687
688
688
@config_class
689
- class ConvProjection (Projection ):
690
- type = 'conv'
691
-
689
+ class ConvBaseProjection (Projection ):
692
690
def __init__ (self ,
693
691
input_layer_name ,
694
692
num_filters = None ,
695
693
conv_conf = None ,
696
694
** xargs ):
697
- super (ConvProjection , self ).__init__ (input_layer_name , ** xargs )
695
+ super (ConvBaseProjection , self ).__init__ (input_layer_name , ** xargs )
698
696
699
697
if num_filters is not None :
700
698
self .proj_conf .num_filters = num_filters
701
699
702
- parse_conv (conv_conf , input_layer_name , self .proj_conf .conv_conf ,
703
- num_filters )
704
- self .proj_conf .output_size = self .proj_conf .conv_conf .output_x * \
705
- self .proj_conf .conv_conf .output_y * \
706
- num_filters
707
-
708
700
def calc_output_size (self , input_layer_config ):
709
701
return self .proj_conf .output_size
710
702
@@ -723,6 +715,46 @@ def calc_parameter_dims(self, input_size, output_size):
723
715
return None
724
716
725
717
718
+ @config_class
719
+ class ConvProjection (ConvBaseProjection ):
720
+ type = 'conv'
721
+
722
+ def __init__ (self ,
723
+ input_layer_name ,
724
+ num_filters = None ,
725
+ conv_conf = None ,
726
+ ** xargs ):
727
+ super (ConvProjection , self ).__init__ (input_layer_name , ** xargs )
728
+
729
+ parse_conv (conv_conf , input_layer_name , self .proj_conf .conv_conf ,
730
+ num_filters )
731
+ self .proj_conf .output_size = self .proj_conf .conv_conf .output_x * \
732
+ self .proj_conf .conv_conf .output_y * \
733
+ num_filters
734
+
735
+
736
+ @config_class
737
+ class ConvTransProjection (ConvBaseProjection ):
738
+ type = 'convt'
739
+
740
+ def __init__ (self ,
741
+ input_layer_name ,
742
+ num_filters = None ,
743
+ conv_conf = None ,
744
+ ** xargs ):
745
+ super (ConvTransProjection , self ).__init__ (input_layer_name , ** xargs )
746
+
747
+ parse_conv (
748
+ conv_conf ,
749
+ input_layer_name ,
750
+ self .proj_conf .conv_conf ,
751
+ num_filters ,
752
+ trans = True )
753
+ self .proj_conf .output_size = self .proj_conf .conv_conf .img_size_y * \
754
+ self .proj_conf .conv_conf .img_size * \
755
+ num_filters
756
+
757
+
726
758
# Define a operator for mixed layer
727
759
@config_class
728
760
class Operator (Cfg ):
@@ -789,6 +821,36 @@ def calc_output_size(self, input_sizes):
789
821
return self .operator_conf .output_size
790
822
791
823
824
+ @config_class
825
+ class ConvTransOperator (Operator ):
826
+ type = 'convt'
827
+
828
+ def __init__ (self ,
829
+ input_layer_names ,
830
+ num_filters = None ,
831
+ conv_conf = None ,
832
+ ** xargs ):
833
+ super (ConvTransOperator , self ).__init__ (input_layer_names , ** xargs )
834
+ if num_filters is not None :
835
+ self .operator_conf .num_filters = num_filters
836
+
837
+ parse_conv (
838
+ conv_conf ,
839
+ MakeLayerNameInSubmodel (input_layer_names [0 ]),
840
+ self .operator_conf .conv_conf ,
841
+ num_filters ,
842
+ trans = True )
843
+ self .operator_conf .output_size = \
844
+ self .operator_conf .conv_conf .img_size * \
845
+ self .operator_conf .conv_conf .img_size_y * \
846
+ num_filters
847
+
848
+ config_assert (len (input_layer_names ) == 2 , "Conv is binary operator" )
849
+
850
+ def calc_output_size (self , input_sizes ):
851
+ return self .operator_conf .output_size
852
+
853
+
792
854
# please refer to the comments in proto/ModelConfig.proto
793
855
@config_class
794
856
class Conv (Cfg ):
0 commit comments