ResNetV2Backbone
classkeras_cv.models.ResNetV2Backbone(
stackwise_filters,
stackwise_blocks,
stackwise_strides,
include_rescaling,
stackwise_dilations=None,
input_shape=(None, None, 3),
input_tensor=None,
block_type="block",
**kwargs
)
Instantiates the ResNetV2 architecture.
Reference
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
True
, inputs will be passed through a Rescaling(1/255.0)
layer.None
(default), dilation will not be used.layers.Input()
)
to use as image input for the model.Examples
input_data = tf.ones(shape=(8, 224, 224, 3))
# Pretrained backbone
model = keras_cv.models.ResNetV2Backbone.from_preset("resnet50_v2_imagenet")
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)
from_preset
methodResNetV2Backbone.from_preset()
Instantiate ResNetV2Backbone model from preset config and weights.
Arguments
None
, which follows whether the preset has
pretrained weights available.Examples
# Load architecture and weights from preset
model = keras_cv.models.ResNetV2Backbone.from_preset(
"resnet50_v2_imagenet",
)
# Load randomly initialized model from preset architecture with weights
model = keras_cv.models.ResNetV2Backbone.from_preset(
"resnet50_v2_imagenet",
load_weights=False,
Preset name | Parameters | Description |
---|---|---|
resnet18_v2 | 11.18M | ResNet model with 18 layers where the batch normalization and ReLU activation precede the convolution layers (v2 style). |
resnet34_v2 | 21.30M | ResNet model with 34 layers where the batch normalization and ReLU activation precede the convolution layers (v2 style). |
resnet50_v2 | 23.56M | ResNet model with 50 layers where the batch normalization and ReLU activation precede the convolution layers (v2 style). |
resnet101_v2 | 42.63M | ResNet model with 101 layers where the batch normalization and ReLU activation precede the convolution layers (v2 style). |
resnet152_v2 | 58.33M | ResNet model with 152 layers where the batch normalization and ReLU activation precede the convolution layers (v2 style). |
resnet50_v2_imagenet | 23.56M | ResNet model with 50 layers where the batch normalization and ReLU activation precede the convolution layers (v2 style). Trained on Imagenet 2012 classification task. |
ResNet18V2Backbone
classkeras_cv.models.ResNet18V2Backbone(
stackwise_filters,
stackwise_blocks,
stackwise_strides,
include_rescaling,
stackwise_dilations=None,
input_shape=(None, None, 3),
input_tensor=None,
block_type="block",
**kwargs
)
ResNetV2Backbone model with 18 layers.
Reference
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
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = ResNet18V2Backbone()
output = model(input_data)
ResNet34V2Backbone
classkeras_cv.models.ResNet34V2Backbone(
stackwise_filters,
stackwise_blocks,
stackwise_strides,
include_rescaling,
stackwise_dilations=None,
input_shape=(None, None, 3),
input_tensor=None,
block_type="block",
**kwargs
)
ResNetV2Backbone model with 34 layers.
Reference
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
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = ResNet34V2Backbone()
output = model(input_data)
ResNet50V2Backbone
classkeras_cv.models.ResNet50V2Backbone(
stackwise_filters,
stackwise_blocks,
stackwise_strides,
include_rescaling,
stackwise_dilations=None,
input_shape=(None, None, 3),
input_tensor=None,
block_type="block",
**kwargs
)
ResNetV2Backbone model with 50 layers.
Reference
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
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = ResNet50V2Backbone()
output = model(input_data)
ResNet101V2Backbone
classkeras_cv.models.ResNet101V2Backbone(
stackwise_filters,
stackwise_blocks,
stackwise_strides,
include_rescaling,
stackwise_dilations=None,
input_shape=(None, None, 3),
input_tensor=None,
block_type="block",
**kwargs
)
ResNetV2Backbone model with 101 layers.
Reference
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
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = ResNet101V2Backbone()
output = model(input_data)
ResNet152V2Backbone
classkeras_cv.models.ResNet152V2Backbone(
stackwise_filters,
stackwise_blocks,
stackwise_strides,
include_rescaling,
stackwise_dilations=None,
input_shape=(None, None, 3),
input_tensor=None,
block_type="block",
**kwargs
)
ResNetV2Backbone model with 152 layers.
Reference
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
True
, inputs will be passed through a Rescaling(1/255.0)
layer.layers.Input()
)
to use as image input for the model.Example
input_data = tf.ones(shape=(8, 224, 224, 3))
# Randomly initialized backbone
model = ResNet152V2Backbone()
output = model(input_data)