MCPcopy Create free account
hub / github.com/10Ring/LAA-Net / forward

Method forward

models/networks/pose_efficientNet.py:99–138  ·  view source on GitHub ↗

MBConvBlock's forward function. Args: inputs (tensor): Input tensor. drop_connect_rate (bool): Drop connect rate (float, between 0 and 1). Returns: Output of this block after processing.

(self, inputs, drop_connect_rate=None)

Source from the content-addressed store, hash-verified

97 self._swish = MemoryEfficientSwish()
98
99 def forward(self, inputs, drop_connect_rate=None):
100 """MBConvBlock's forward function.
101 Args:
102 inputs (tensor): Input tensor.
103 drop_connect_rate (bool): Drop connect rate (float, between 0 and 1).
104 Returns:
105 Output of this block after processing.
106 """
107
108 # Expansion and Depthwise Convolution
109 x = inputs
110 if self._block_args.expand_ratio != 1:
111 x = self._expand_conv(inputs)
112 x = self._bn0(x)
113 x = self._swish(x)
114
115 x = self._depthwise_conv(x)
116 x = self._bn1(x)
117 x = self._swish(x)
118
119 # Squeeze and Excitation
120 if self.has_se:
121 x_squeezed = F.adaptive_avg_pool2d(x, 1)
122 x_squeezed = self._se_reduce(x_squeezed)
123 x_squeezed = self._swish(x_squeezed)
124 x_squeezed = self._se_expand(x_squeezed)
125 x = torch.sigmoid(x_squeezed) * x
126
127 # Pointwise Convolution
128 x = self._project_conv(x)
129 x = self._bn2(x)
130
131 # Skip connection and drop connect
132 input_filters, output_filters = self._block_args.input_filters, self._block_args.output_filters
133 if self.id_skip and self._block_args.stride == 1 and input_filters == output_filters:
134 # The combination of skip connection and drop connect brings about stochastic depth.
135 if drop_connect_rate:
136 x = drop_connect(x, p=drop_connect_rate, training=self.training)
137 x = x + inputs # skip connection
138 return x
139
140 def set_swish(self, memory_efficient=True):
141 """Sets swish function as memory efficient (for training) or standard (for export).

Callers

nothing calls this directly

Calls 1

drop_connectFunction · 0.85

Tested by

no test coverage detected