#23764·keras

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)

https://github.com/keras-team/keras/blob/58db6d637b6119d2c6a21dcf84119a2f1cba4f4c/keras/src/applications/mobilenet.py#L119-L124

https://github.com/keras-team/keras/blob/58db6d637b6119d2c6a21dcf84119a2f1cba4f4c/keras/src/applications/mobilenet.py#L158-L164

https://github.com/keras-team/keras/blob/58db6d637b6119d2c6a21dcf84119a2f1cba4f4c/keras/src/applications/mobilenet.py#L166-L172

In mobilenet_v2.py: (the first one is described properly in comments)

https://github.com/keras-team/keras/blob/58db6d637b6119d2c6a21dcf84119a2f1cba4f4c/keras/src/applications/mobilenet_v2.py#L121-L125

https://github.com/keras-team/keras/blob/58db6d637b6119d2c6a21dcf84119a2f1cba4f4c/keras/src/applications/mobilenet_v2.py#L226-L233

In mobilenet_v3.py: (the second one is fixed in https://github.com/keras-team/keras/pull/21563)

https://github.com/keras-team/keras/blob/58db6d637b6119d2c6a21dcf84119a2f1cba4f4c/keras/src/applications/mobilenet_v3.py#L179-L184

https://github.com/keras-team/keras/blob/58db6d637b6119d2c6a21dcf84119a2f1cba4f4c/keras/src/applications/mobilenet_v3.py#L270-L281

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

python
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=2

Thanks for noting!