ResNetV2
Keras
Model Details
Instantiates the ResNetV2 architecture.
Reference
- 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
- stackwise_filters: list of ints, number of filters for each stack in the model.
- stackwise_blocks: list of ints, number of blocks for each stack in the model.
- stackwise_strides: list of ints, stride for each stack in the model.
- include_rescaling: bool, whether to rescale the inputs. If set to
True
, inputs will be passed through aRescaling(1/255.0)
layer. - stackwise_dilations: list of ints, dilation for each stack in the model. If
None
(default), dilation will not be used. - input_shape: optional shape tuple, defaults to (None, None, 3).
- input_tensor: optional Keras tensor (i.e. output of
layers.Input()
) to use as image input for the model. - 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)
0 comments
No comments yet.