Fix several Doc issues for `mobilenet`, `mobilenet_v2`, and `mobilenet_v3`
Author: ILCSFNOCreated Sep 25, 2026Updated Sep 28, 2026
Labelstype:docsGood first issue
Doc Issue
Same as #21562, several docs of mobilenet should be fixed:
In mobilenet.py: (the first one is described properly in comments)
In mobilenet_v2.py: (the first one is described properly in comments)
In mobilenet_v3.py: (the second one is fixed in https://github.com/keras-team/keras/pull/21563)
The version I tried is TensorFlow 2.19.0 and TensorFlow 2.21.0:
One of the sample repros is shown below. I accept that it should raise error, but should be noted in docs that there are several limitations when we weights is set to imagenet.
Repro
import tensorflow as tf
import numpy as np
input_data = np.random.rand(1, 128, 128, 3).astype('float32') * 2 - 1
model = tf.keras.applications.MobileNet(
input_shape=(128, 128, 3),
alpha=0.75,
depth_multiplier=2,
include_top=False,
weights='imagenet'
)
processed_data = tf.keras.applications.mobilenet.preprocess_input(input_data)
output = model(processed_data)
print(f"Input shape: {input_data.shape}")
print(f"Output shape: {output.shape}")
print(f"Output max value: {np.max(output.numpy())}")
print(f"Output min value: {np.min(output.numpy())}")Output
ValueError: If imagenet weights are being loaded, depth multiplier must be 1. Received depth_multiplier=2Thanks for noting!
Source: keras-team/keras