def forward(self, x, y, step): x = self.x_op(x) y = self.y_op(y) X_DROP = False Y_DROP = False if self.search_space == 'small': if self.drop_path_keep_prob is not None and self.training: X_DROP = True if self.drop_path_keep_prob is not None and self.training: Y_DROP = True elif self.search_space == 'middle': if self.drop_path_keep_prob is not None and self.training: X_DROP = True if self.drop_path_keep_prob is not None and self.training: Y_DROP = True elif self.search_space == 'large': if self.drop_path_keep_prob is not None and self.training: X_DROP = True if self.drop_path_keep_prob is not None and self.training: Y_DROP = True if X_DROP: x = apply_drop_path(x, self.drop_path_keep_prob, self.layer_id, self.layers, step, self.steps) if Y_DROP: y = apply_drop_path(y, self.drop_path_keep_prob, self.layer_id, self.layers, step, self.steps) out = x + y return out
def forward(self, x, x_id, x_op, y, y_id, y_op, step, bn_train=False): stride = self.stride if x_id in [0, 1] else 1 x = self.x_op[x_op](x, x_id, stride, bn_train) stride = self.stride if y_id in [0, 1] else 1 y = self.y_op[y_op](y, y_id, stride, bn_train) X_DROP = False Y_DROP = False if self.search_space == 'small': if x_op not in [ 4 ] and self.drop_path_keep_prob is not None and self.training: X_DROP = True if y_op not in [ 4 ] and self.drop_path_keep_prob is not None and self.training: Y_DROP = True elif self.search_space == 'middle': if x_op not in [ 0, 1 ] and self.drop_path_keep_prob is not None and self.training: X_DROP = True if y_op not in [ 0, 1 ] and self.drop_path_keep_prob is not None and self.training: Y_DROP = True if X_DROP: x = apply_drop_path(x, self.drop_path_keep_prob, self.layer_id, self.layers, step, self.steps) if Y_DROP: y = apply_drop_path(y, self.drop_path_keep_prob, self.layer_id, self.layers, step, self.steps) return x + y
def forward(self, x, y, step): if self.x_op_id in [10, 13]: x = F.pad(x, [0, 1, 0, 1]) x = self.x_op(x) if self.x_id_fact_reduce is not None: x = self.x_id_fact_reduce(x) if self.drop_path_keep_prob is not None and self.training: x = apply_drop_path(x, self.drop_path_keep_prob, self.layer_id, self.layers, step, self.steps) if self.y_op_id in [10, 13]: y = F.pad(y, [0, 1, 0, 1]) y = self.y_op(y) if self.y_id_fact_reduce is not None: y = self.y_id_fact_reduce(y) if self.drop_path_keep_prob is not None and self.training: y = apply_drop_path(y, self.drop_path_keep_prob, self.layer_id, self.layers, step, self.steps) out = x + y return out
def call(self, x, y=None, step=None, training=False, **kwargs): x = self.x_op(x, training=training) if self.x_id_fact_reduce is not None: x = self.x_id_fact_reduce(x, training=training) if self.drop_path_keep_prob is not None and training: x = apply_drop_path(x, self.drop_path_keep_prob, self.cell_id, self.num_cells, step, self.steps) y = self.y_op(y) if self.y_id_fact_reduce is not None: y = self.y_id_fact_reduce(y, training=training) if self.drop_path_keep_prob is not None and training: y = apply_drop_path(y, self.drop_path_keep_prob, self.cell_id, self.num_cells, step, self.steps) out = x + y return out
def forward(self, x, x_id, x_op, y, y_id, y_op, step, bn_train=False): stride = self.stride if x_id in [0, 1] else 1 if x_op == 0: x = self.x_sep_conv_3(x, x_id, stride, bn_train=bn_train) elif x_op == 1: x = self.x_sep_conv_5(x, x_id, stride, bn_train=bn_train) elif x_op == 2: x = self.x_avg_pool(x, stride) elif x_op == 3: x = self.x_max_pool(x, stride) else: assert x_op == 4 if stride > 1: assert stride == 2 if x_id == 0: x = self.x_id_reduce_1(x, bn_train=bn_train) else: x = self.x_id_reduce_2(x, bn_train=bn_train) stride = self.stride if y_id in [0, 1] else 1 if y_op == 0: y = self.y_sep_conv_3(y, y_id, stride, bn_train=bn_train) elif y_op == 1: y = self.y_sep_conv_5(y, y_id, stride, bn_train=bn_train) elif y_op == 2: y = self.y_avg_pool(y, stride) elif y_op == 3: y = self.y_max_pool(y, stride) else: assert y_op == 4 if stride > 1: assert stride == 2 if y_id == 0: y = self.x_id_reduce_1(y, bn_train=bn_train) else: y = self.x_id_reduce_2(y, bn_train=bn_train) if x_op != 4 and self.drop_path_keep_prob is not None and self.training: x = apply_drop_path(x, self.drop_path_keep_prob, self.layer_id, self.layers, step, self.steps) if y_op != 4 and self.drop_path_keep_prob is not None and self.training: y = apply_drop_path(y, self.drop_path_keep_prob, self.layer_id, self.layers, step, self.steps) return x + y