This implements the Deep Residual Network from:
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun.
Deep Residual Learning for Image Recognition.
(https://arxiv.org/pdf/1512.03385) and
Irwan Bello, William Fedus, Xianzhi Du, Ekin D. Cubuk, Aravind Srinivas,
Tsung-Yi Lin, Jonathon Shlens, Barret Zoph.
Revisiting ResNets: Improved Training and Scaling Strategies.
(https://arxiv.org/abs/2103.07579).
Args
model_id
An int of the depth of ResNet backbone model.
input_specs
A tf_keras.layers.InputSpec of the input tensor.
depth_multiplier
A float of the depth multiplier to uniformaly scale up
all layers in channel size. This argument is also referred to as
width_multiplier in (https://arxiv.org/abs/2103.07579).
stem_type
A str of stem type of ResNet. Default to v0. If set to
v1, use ResNet-D type stem (https://arxiv.org/abs/1812.01187).
resnetd_shortcut
A bool of whether to use ResNet-D shortcut in
downsampling blocks.
replace_stem_max_pool
A bool of whether to replace the max pool in stem
with a stride-2 conv,
se_ratio
A float or None. Ratio of the Squeeze-and-Excitation layer.
init_stochastic_depth_rate
A float of initial stochastic depth rate.
upsample_repeats
A list for upsample repeats of the ConvNext blocks for
each level starting from L5, then L4, and so on.
upsample_filters
A list for the upsample filter sizes for the ConvNext
blocks for each level.
upsample_kernel_sizes
A list for upsample kernel sizes for the ConvNext
blocks for each level.
scale_stem
A bool of whether to scale stem layers.
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.
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.
bn_trainable
A bool that indicates whether batch norm layers should be
trainable. Default to True.
classification_output
A bool to output the correct level needed for
classification (L3), only set to True for pretraining.
**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).
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-11-06 UTC."],[],[]]