Skip to content

Commit

Permalink
Add name arg to MobileNet V1 and V2 (#19712)
Browse files Browse the repository at this point in the history
Followup from #19695 and 2b7120b.
  • Loading branch information
jeffcarp authored May 13, 2024
1 parent 310c275 commit 669a97a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion keras/src/applications/mobilenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def MobileNet(
pooling=None,
classes=1000,
classifier_activation="softmax",
name=None,
):
"""Instantiates the MobileNet architecture.
Expand Down Expand Up @@ -101,6 +102,7 @@ def MobileNet(
Set `classifier_activation=None` to return the logits of the "top"
layer. When loading pretrained weights, `classifier_activation`
can only be `None` or `"softmax"`.
name: String, the name of the model.
Returns:
A model instance.
Expand Down Expand Up @@ -237,7 +239,9 @@ def MobileNet(
inputs = img_input

# Create model.
model = Functional(inputs, x, name=f"mobilenet_{alpha:0.2f}_{rows}")
if name is None:
name = f"mobilenet_{alpha:0.2f}_{rows}"
model = Functional(inputs, x, name=name)

# Load weights.
if weights == "imagenet":
Expand Down
6 changes: 5 additions & 1 deletion keras/src/applications/mobilenet_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def MobileNetV2(
pooling=None,
classes=1000,
classifier_activation="softmax",
name=None,
):
"""Instantiates the MobileNetV2 architecture.
Expand Down Expand Up @@ -103,6 +104,7 @@ def MobileNetV2(
Set `classifier_activation=None` to return the logits of the "top"
layer. When loading pretrained weights, `classifier_activation`
can only be `None` or `"softmax"`.
name: String, the name of the model.
Returns:
A model instance.
Expand Down Expand Up @@ -359,7 +361,9 @@ def MobileNetV2(
inputs = img_input

# Create model.
model = Functional(inputs, x, name=f"mobilenetv2_{alpha:0.2f}_{rows}")
if name is None:
name = f"mobilenetv2_{alpha:0.2f}_{rows}"
model = Functional(inputs, x, name=name)

# Load weights.
if weights == "imagenet":
Expand Down
1 change: 1 addition & 0 deletions keras/src/applications/mobilenet_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
be `None` or `"softmax"`.
include_preprocessing: Boolean, whether to include the preprocessing
layer (`Rescaling`) at the bottom of the network. Defaults to `True`.
name: String, the name of the model.
Call arguments:
inputs: A floating point `numpy.array` or backend-native tensor,
Expand Down

0 comments on commit 669a97a

Please sign in to comment.