| 134 | return x |
| 135 | |
| 136 | class HECTOR(nn.Module): |
| 137 | def __init__( |
| 138 | self, |
| 139 | input_feature_size=1024, |
| 140 | precompression_layer=True, |
| 141 | feature_size_comp = 512, |
| 142 | feature_size_attn = 256, |
| 143 | postcompression_layer=True, |
| 144 | feature_size_comp_post = 128, |
| 145 | dropout=True, |
| 146 | p_dropout_fc=0.25, |
| 147 | p_dropout_atn=0.25, |
| 148 | n_classes=2, |
| 149 | input_stage_size=6, |
| 150 | embedding_dim_stage=16, |
| 151 | depth_dim_stage=1, |
| 152 | act_fct_stage='elu', |
| 153 | dropout_stage=True, |
| 154 | p_dropout_stage=0.25, |
| 155 | input_mol_size=4, |
| 156 | embedding_dim_mol=16, |
| 157 | depth_dim_mol=1, |
| 158 | act_fct_mol='elu', |
| 159 | dropout_mol=True, |
| 160 | p_dropout_mol=0.25, |
| 161 | fusion_type='kron', |
| 162 | use_bilinear=[True,True,True], |
| 163 | gate_hist=False, |
| 164 | gate_stage=False, |
| 165 | gate_mol=False, |
| 166 | scale=[1,1,1], |
| 167 | ): |
| 168 | super(HECTOR, self).__init__() |
| 169 | |
| 170 | self.fusion_type =fusion_type |
| 171 | self.input_stage_size=input_stage_size |
| 172 | self.use_bilinear = use_bilinear |
| 173 | self.gate_hist = gate_hist |
| 174 | self.gate_stage = gate_stage |
| 175 | self.gate_mol = gate_mol |
| 176 | |
| 177 | # Reduce dimension of H&E patch features. |
| 178 | if precompression_layer: |
| 179 | self.compression_layer = nn.Sequential(*[FC_block(input_feature_size, feature_size_comp*4, p_dropout_fc=p_dropout_fc), |
| 180 | FC_block(feature_size_comp*4, feature_size_comp*2, p_dropout_fc=p_dropout_fc), |
| 181 | FC_block(feature_size_comp*2, feature_size_comp, p_dropout_fc=p_dropout_fc),]) |
| 182 | |
| 183 | dim_post_compression = feature_size_comp |
| 184 | else: |
| 185 | self.compression_layer = nn.Identity() |
| 186 | dim_post_compression = input_feature_size |
| 187 | |
| 188 | # Get embeddings of categorical features. |
| 189 | self.encoding_stage_net = Categorical_encoding(taxonomy_in=self.input_stage_size, |
| 190 | embedding_dim=embedding_dim_stage, |
| 191 | depth=depth_dim_stage, |
| 192 | act_fct=act_fct_stage, |
| 193 | dropout=dropout_stage, |
no outgoing calls
no test coverage detected