tests/experimental/tensorflow/test_models/resnet.py
def _block_group(self,
                     inputs: tf.Tensor,
                     filters: int,
                     strides: int,
                     block_fn: Callable[..., tf.keras.layers.Layer],
                     block_repeats: int = 1,
                     stochastic_depth_drop_rate: float = 0.0,
                     name: str = 'block_group'):
        """Creates one group of blocks for the ResNet model.

        Args:
          inputs: A `tf.Tensor` of size `[batch, channels, height, width]`.
          filters: An `int` number of filters for the first convolution of the
            layer.
          strides: An `int` stride to use for the first convolution of the layer.
            If greater than 1, this layer will downsample the input.
          block_fn: The type of block group. Either `ResidualBlock` or
            `BottleneckBlock`.
          block_repeats: An `int` number of blocks contained in the layer.
          stochastic_depth_drop_rate: A `float` of drop rate of the current block
            group.
          name: A `str` name for the block.

        Returns:
          The output `tf.Tensor` of the block layer.
        """
        x = block_fn(
            filters=filters,
            strides=strides,
            use_projection=True,
            stochastic_depth_drop_rate=stochastic_depth_drop_rate,
            se_ratio=self._se_ratio,
            resnetd_shortcut=self._resnetd_shortcut,
            kernel_initializer=self._kernel_initializer,
            kernel_regularizer=self._kernel_regularizer,
            bias_regularizer=self._bias_regularizer,
            activation=self._activation,
            use_sync_bn=self._use_sync_bn,
            norm_momentum=self._norm_momentum,
            norm_epsilon=self._norm_epsilon,
            bn_trainable=self._bn_trainable)(
                inputs)

        for _ in range(1, block_repeats):
            x = block_fn(
                filters=filters,
                strides=1,
                use_projection=False,
                stochastic_depth_drop_rate=stochastic_depth_drop_rate,
                se_ratio=self._se_ratio,
                resnetd_shortcut=self._resnetd_shortcut,
                kernel_initializer=self._kernel_initializer,
                kernel_regularizer=self._kernel_regularizer,
                bias_regularizer=self._bias_regularizer,
                activation=self._activation,
                use_sync_bn=self._use_sync_bn,
                norm_momentum=self._norm_momentum,
                norm_epsilon=self._norm_epsilon,
                bn_trainable=self._bn_trainable)(
                    x)

        return tf.keras.layers.Activation('linear', name=name)(x)
Creates one group of blocks for the ResNet model.

        Args:
          inputs: A `tf.Tensor` of size `[batch, channels, height, width]`.
          filters: An `int` number of filters for the first convolution of the
            layer.
          strides: An `int` stride to use for the first convolution of the layer.
            If greater than 1, this layer will downsample the input.
          block_fn: The type of block group. Either `ResidualBlock` or
            `BottleneckBlock`.
          block_repeats: An `int` number of blocks contained in the layer.
          stochastic_depth_drop_rate: A `float` of drop rate of the current block
            group.
          name: A `str` name for the block.

        Returns:
          The output `tf.Tensor` of the block layer.
        
Creates one group of blocks for the ResNet model.
Creates one group of blocks for the ResNet model .
def _block_group(self,
                     inputs: tf.Tensor,
                     filters: int,
                     strides: int,
                     block_fn: Callable[..., tf.keras.layers.Layer],
                     block_repeats: int = 1,
                     stochastic_depth_drop_rate: float = 0.0,
                     name: str = 'block_group'):
        x = block_fn(
            filters=filters,
            strides=strides,
            use_projection=True,
            stochastic_depth_drop_rate=stochastic_depth_drop_rate,
            se_ratio=self._se_ratio,
            resnetd_shortcut=self._resnetd_shortcut,
            kernel_initializer=self._kernel_initializer,
            kernel_regularizer=self._kernel_regularizer,
            bias_regularizer=self._bias_regularizer,
            activation=self._activation,
            use_sync_bn=self._use_sync_bn,
            norm_momentum=self._norm_momentum,
            norm_epsilon=self._norm_epsilon,
            bn_trainable=self._bn_trainable)(
                inputs)
        for _ in range(1, block_repeats):
            x = block_fn(
                filters=filters,
                strides=1,
                use_projection=False,
                stochastic_depth_drop_rate=stochastic_depth_drop_rate,
                se_ratio=self._se_ratio,
                resnetd_shortcut=self._resnetd_shortcut,
                kernel_initializer=self._kernel_initializer,
                kernel_regularizer=self._kernel_regularizer,
                bias_regularizer=self._bias_regularizer,
                activation=self._activation,
                use_sync_bn=self._use_sync_bn,
                norm_momentum=self._norm_momentum,
                norm_epsilon=self._norm_epsilon,
                bn_trainable=self._bn_trainable)(
                    x)
        return tf.keras.layers.Activation('linear', name=name)(x)
def _block_group ( self , inputs : tf . Tensor , filters : int , strides : int , block_fn : Callable [ ... , tf . keras . layers . Layer ] , block_repeats : int = 1 , stochastic_depth_drop_rate : float = 0.0 , name : str = 'block_group' ) : x = block_fn ( filters = filters , strides = strides , use_projection = True , stochastic_depth_drop_rate = stochastic_depth_drop_rate , se_ratio = self . _se_ratio , resnetd_shortcut = self . _resnetd_shortcut , kernel_initializer = self . _kernel_initializer , kernel_regularizer = self . _kernel_regularizer , bias_regularizer = self . _bias_regularizer , activation = self . _activation , use_sync_bn = self . _use_sync_bn , norm_momentum = self . _norm_momentum , norm_epsilon = self . _norm_epsilon , bn_trainable = self . _bn_trainable ) ( inputs ) for _ in range ( 1 , block_repeats ) : x = block_fn ( filters = filters , strides = 1 , use_projection = False , stochastic_depth_drop_rate = stochastic_depth_drop_rate , se_ratio = self . _se_ratio , resnetd_shortcut = self . _resnetd_shortcut , kernel_initializer = self . _kernel_initializer , kernel_regularizer = self . _kernel_regularizer , bias_regularizer = self . _bias_regularizer , activation = self . _activation , use_sync_bn = self . _use_sync_bn , norm_momentum = self . _norm_momentum , norm_epsilon = self . _norm_epsilon , bn_trainable = self . _bn_trainable ) ( x ) return tf . keras . layers . Activation ( 'linear' , name = name ) ( x )
Creates one group of blocks for the ResNet model.
Creates one group of blocks for the ResNet model .
"""Creates one group of blocks for the ResNet model.

        Args:
          inputs: A `tf.Tensor` of size `[batch, channels, height, width]`.
          filters: An `int` number of filters for the first convolution of the
            layer.
          strides: An `int` stride to use for the first convolution of the layer.
            If greater than 1, this layer will downsample the input.
          block_fn: The type of block group. Either `ResidualBlock` or
            `BottleneckBlock`.
          block_repeats: An `int` number of blocks contained in the layer.
          stochastic_depth_drop_rate: A `float` of drop rate of the current block
            group.
          name: A `str` name for the block.

        Returns:
          The output `tf.Tensor` of the block layer.
        """
The output `tf.Tensor` of the block layer.
The output ` tf . Tensor ` of the block layer .
self
inputs
tf.Tensor
A `tf.Tensor` of size `[batch, channels, height, width]`.
A ` tf . Tensor ` of size ` [ batch channels height width ] ` .
filters
int
An `int` number of filters for the first convolution of the
layer.
An ` int ` number of filters for the first convolution of the layer .
strides
int
An `int` stride to use for the first convolution of the layer.
If greater than 1, this layer will downsample the input.
An ` int ` stride to use for the first convolution of the layer . If greater than 1 this layer will downsample the input .
block_fn
Callable[..., tf.keras.layers.Layer]
The type of block group. Either `ResidualBlock` or
`BottleneckBlock`.
The type of block group . Either ` ResidualBlock ` or ` BottleneckBlock ` .
block_repeats
int
An `int` number of blocks contained in the layer.
An ` int ` number of blocks contained in the layer .
stochastic_depth_drop_rate
float
A `float` of drop rate of the current block
group.
A ` float ` of drop rate of the current block group .
name
str
A `str` name for the block.
A ` str ` name for the block .