DenseNetBackbone
classkeras_cv.models.DenseNetBackbone(
stackwise_num_repeats,
include_rescaling,
input_shape=(None, None, 3),
input_tensor=None,
compression_ratio=0.5,
growth_rate=32,
**kwargs
)
Instantiates the DenseNet architecture.
Arguments
True
, inputs will be passed through a Rescaling(1/255.0)
layer.keras.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.DenseNetBackbone.from_preset("densenet121_imagenet")
output = model(input_data)
# Randomly initialized backbone with a custom config
model = DenseNetBackbone(
stackwise_num_repeats=[6, 12, 24, 16],
include_rescaling=False,
)
output = model(input_data)
from_preset
methodDenseNetBackbone.from_preset()
Instantiate DenseNetBackbone 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.DenseNetBackbone.from_preset(
"densenet121_imagenet",
)
# Load randomly initialized model from preset architecture with weights
model = keras_cv.models.DenseNetBackbone.from_preset(
"densenet121_imagenet",
load_weights=False,
Preset name | Parameters | Description |
---|---|---|
densenet121 | Unknown | DenseNet model with 121 layers. |
densenet169 | Unknown | DenseNet model with 169 layers. |
densenet201 | Unknown | DenseNet model with 201 layers. |
densenet121_imagenet | Unknown | DenseNet model with 121 layers. Trained on Imagenet 2012 classification task. |
densenet169_imagenet | Unknown | DenseNet model with 169 layers. Trained on Imagenet 2012 classification task. |
densenet201_imagenet | Unknown | DenseNet model with 201 layers. Trained on Imagenet 2012 classification task. |
DenseNet121Backbone
classkeras_cv.models.DenseNet121Backbone(
stackwise_num_repeats,
include_rescaling,
input_shape=(None, None, 3),
input_tensor=None,
compression_ratio=0.5,
growth_rate=32,
**kwargs
)
DenseNetBackbone model with 121 layers.
Reference
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 = DenseNet121Backbone()
output = model(input_data)
DenseNet169Backbone
classkeras_cv.models.DenseNet169Backbone(
stackwise_num_repeats,
include_rescaling,
input_shape=(None, None, 3),
input_tensor=None,
compression_ratio=0.5,
growth_rate=32,
**kwargs
)
DenseNetBackbone model with 169 layers.
Reference
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 = DenseNet169Backbone()
output = model(input_data)
DenseNet201Backbone
classkeras_cv.models.DenseNet201Backbone(
stackwise_num_repeats,
include_rescaling,
input_shape=(None, None, 3),
input_tensor=None,
compression_ratio=0.5,
growth_rate=32,
**kwargs
)
DenseNetBackbone model with 201 layers.
Reference
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 = DenseNet201Backbone()
output = model(input_data)