Creates a SpineNet family model.
tfm.vision.backbones.SpineNet(
input_specs: tf.keras.layers.InputSpec = tf.keras.layers.InputSpec(shape=[None, None, None, 3]),
min_level: int = 3,
max_level: int = 7,
block_specs: Optional[List[BlockSpec]] = None,
endpoints_num_filters: int = 256,
resample_alpha: float = 0.5,
block_repeats: int = 1,
filter_size_scale: float = 1.0,
init_stochastic_depth_rate: float = 0.0,
kernel_initializer: str = 'VarianceScaling',
kernel_regularizer: Optional[tf.keras.regularizers.Regularizer] = None,
bias_regularizer: Optional[tf.keras.regularizers.Regularizer] = None,
activation: str = 'relu',
use_sync_bn: bool = False,
norm_momentum: float = 0.99,
norm_epsilon: float = 0.001,
**kwargs
)
This implements
Xianzhi Du, Tsung-Yi Lin, Pengchong Jin, Golnaz Ghiasi, Mingxing Tan,
Yin Cui, Quoc V. Le, Xiaodan Song.
SpineNet
Learning Scale-Permuted Backbone for Recognition and Localization.
(https://arxiv.org/abs/1912.05027)
Args
input_specs
A tf.keras.layers.InputSpec
of the input tensor.
min_level
An int
of min level for output mutiscale features.
max_level
An int
of max level for output mutiscale features.
block_specs
A list of block specifications for the SpineNet model
discovered by NAS.
endpoints_num_filters
An int
of feature dimension for the output
endpoints.
resample_alpha
A float
of resampling factor in cross-scale connections.
block_repeats
An int
of number of blocks contained in the layer.
filter_size_scale
A float
of multiplier for the filters (number of
channels) for all convolution ops. The value must be greater than zero.
Typical usage will be to set this value in (0, 1) to reduce the number
of parameters or computation cost of the model.
init_stochastic_depth_rate
A float
of initial stochastic depth rate.
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
name of the activation function.
use_sync_bn
If True, use synchronized batch normalization.
norm_momentum
A float
of normalization momentum for the moving average.
norm_epsilon
A small 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.