ResNetV2

Keras

Model Details

Instantiates the ResNetV2 architecture.


Reference

  1. Identity Mappings in Deep Residual Networks (ECCV 2016)

The difference in Resnet and ResNetV2 rests in the structure of their individual building blocks. In ResNetV2, the batch normalization and ReLU activation precede the convolution layers, as opposed to ResNetV1 where the batch normalization and ReLU activation are applied after the convolution layers.

For transfer learning use cases, make sure to read the guide to transfer learning & fine-tuning.


Arguments

  1. stackwise_filters: list of ints, number of filters for each stack in the model.
  2. stackwise_blocks: list of ints, number of blocks for each stack in the model.
  3. stackwise_strides: list of ints, stride for each stack in the model.
  4. include_rescaling: bool, whether to rescale the inputs. If set to True, inputs will be passed through a Rescaling(1/255.0) layer.
  5. stackwise_dilations: list of ints, dilation for each stack in the model. If None (default), dilation will not be used.
  6. input_shape: optional shape tuple, defaults to (None, None, 3).
  7. input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
  8. block_type: string, one of "basic_block" or "block". The block type to stack. Use "basic_block" for smaller models like ResNet18 and ResNet34.


Example Use

import keras_cv
import keras_core as keras
import numpy as np
input_data = tf.ones(shape=(8, 224, 224, 3))

# Pretrained backbone
model = keras_cv.models.ResNetV2Backbone.from_preset("resnet101_v2")
output = model(input_data)

# Randomly initialized backbone with a custom config
model = ResNetV2Backbone(
stackwise_filters=[64, 128, 256, 512],
stackwise_blocks=[2, 2, 2, 2],
stackwise_strides=[1, 2, 2, 2],
include_rescaling=False,
)
output = model(input_data)



Model Comments

0 comments

No comments yet.