in tensorflow/sagemakercv/detection/backbones/resnet.py [0:0]
def call(self, inputs, training=False):
"""
Args:
inputs: `Tensor` of size `[batch, channels, height, width]`.
Returns:
The output `Tensor` of the block.
"""
try:
# Projection shortcut in first layer to match filters and strides
shortcut = self._local_layers["projection"]["conv2d"](inputs=inputs)
if self.norm_type == 'batchnorm':
shortcut = self._local_layers["projection"]["batchnorm"](
inputs=shortcut,
training=training and self._trainable and self._finetune_bn
)
elif self.norm_type == 'groupnorm':
shortcut = self._local_layers["projection"]["groupnorm"](
inputs=shortcut,
training=training
)
except KeyError:
shortcut = inputs
net = inputs
for i in range(1, 3):
net = self._local_layers["conv2d_%d" % i](inputs=net)
if self.norm_type == 'batchnorm':
net = self._local_layers["batchnorm_%d" % i](
inputs=net,
training=training and self._trainable and self._finetune_bn
)
elif self.norm_type == 'groupnorm':
net = self._local_layers["groupnorm_%d" % i](
inputs=net,
training=training
)
return self._local_layers["activation"](net + shortcut)