Beispiel #1
0
    def forward(self, x):
        residual = x

        # Point-wise expansion
        x = self.conv_pw(x)
        x = self.bn1(x)
        x = self.act1(x)

        # Depth-wise convolution
        x = self.conv_dw(x)
        x = self.bn2(x)
        x = self.act2(x)

        # Squeeze-and-excitation
        if self.se is not None:
            x = self.se(x)

        # Point-wise linear projection
        x = self.conv_pwl(x)
        x = self.bn3(x)

        if self.has_residual:
            if self.downsample is not None:
                residual = self.downsample(residual)
            if self.drop_path_rate > 0.:
                x = drop_path(x, self.drop_path_rate, self.training)
            x += residual

        return x
Beispiel #2
0
	def forward(self, x):
		if self.conv is None or isinstance(self.conv, ZeroLayer):
			res = x
		elif self.shortcut is None or isinstance(self.shortcut, ZeroLayer):
			res = self.conv(x)
		else:
			shortcut = self.shortcut(x)
			x = self.conv(x)
			if self.drop_path_rate > 0.:
				x = drop_path(x, self.drop_path_rate, self.training)
			res = x + shortcut
		return res
Beispiel #3
0
 def forward(self, x):
     outputs = []
     for level in range(self.config.num_levels):
         x_level = x[level]
         for i in range(self.config.box_class_repeats):
             x_level_ident = x_level
             x_level = self.conv_rep[i](x_level)
             x_level = self.bn_rep[i][level](x_level)
             x_level = self.act(x_level)
             if i > 0 and self.config.fpn_drop_path_rate:
                 x_level = drop_path(x_level, self.config.fpn_drop_path_rate, self.training)
                 x_level += x_level_ident
         outputs.append(self.predict(x_level))
     return outputs
Beispiel #4
0
    def forward(self, x):
        if self.mobile_inverted_conv is None or isinstance(self.mobile_inverted_conv, ZeroLayer):
            res = x
        elif self.shortcut is None or isinstance(self.shortcut, ZeroLayer):
            res = self.mobile_inverted_conv(x)
        else:
            # res = self.mobile_inverted_conv(x) + self.shortcut(x)
            res = self.mobile_inverted_conv(x)

            if self.drop_connect_rate > 0.:
                res = drop_path(res, drop_prob=self.drop_connect_rate, training=self.training)

            res += self.shortcut(x)

        return res
Beispiel #5
0
 def forward(self, x):
     return drop_path(x, self.drop_prob, self.training)