Creates an EfficientNet family model.
tfm.vision.backbones.EfficientNet(
model_id: str,
input_specs: tf.keras.layers.InputSpec = layers.InputSpec(shape=[None, None, None, 3]),
se_ratio: float = 0.0,
stochastic_depth_drop_rate: float = 0.0,
kernel_initializer: str = 'VarianceScaling',
kernel_regularizer: tf.keras.regularizers.Regularizer = None,
bias_regularizer: tf.keras.regularizers.Regularizer = None,
activation: str = 'relu',
se_inner_activation: str = 'relu',
use_sync_bn: bool = False,
norm_momentum: float = 0.99,
norm_epsilon: float = 0.001,
**kwargs
)
This implements the EfficientNet model from:
Mingxing Tan, Quoc V. Le.
EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks.
(https://arxiv.org/pdf/1905.11946 )
Args
model_id
A str
of model ID of EfficientNet.
input_specs
A tf.keras.layers.InputSpec
of the input tensor.
se_ratio
A float
of squeeze and excitation ratio for inverted
bottleneck blocks.
stochastic_depth_drop_rate
A float
of drop rate for drop connect layer.
kernel_initializer
A str
for kernel initializer of convolutional
layers.
kernel_regularizer
A tf.keras.regularizers.Regularizer
object for
Conv2D. Default to None.
bias_regularizer
A tf.keras.regularizers.Regularizer
object for Conv2D.
Default to None.
activation
A str
of name of the activation function.
se_inner_activation
A str
of name of the activation function used in
Sequeeze and Excitation layer.
use_sync_bn
If True, use synchronized batch normalization.
norm_momentum
A float
of normalization momentum for the moving average.
norm_epsilon
A float
added to variance to avoid dividing by zero.
**kwargs
Additional keyword arguments to be passed.
Attributes
output_specs
A dict of {level: TensorShape} pairs for the model output.
Methods
call
call(
inputs, training=None, mask=None
)
Calls the model on new inputs and returns the outputs as tensors.
In this case call()
just reapplies
all ops in the graph to the new inputs
(e.g. build a new computational graph from the provided inputs).
Note: This method should not be called directly. It is only meant to be
overridden when subclassing tf.keras.Model
.
To call a model on an input, always use the __call__()
method,
i.e. model(inputs)
, which relies on the underlying call()
method.
Args
inputs
Input tensor, or dict/list/tuple of input tensors.
training
Boolean or boolean scalar tensor, indicating whether to
run the Network
in training mode or inference mode.
mask
A mask or list of masks. A mask can be either a boolean tensor
or None (no mask). For more details, check the guide
here .
Returns
A tensor if there is a single output, or
a list of tensors if there are more than one outputs.