Skip to content

Comments

fix(research): replace deprecated np.int with int in mobilenet_v3#13609

Merged
marksandler2 merged 1 commit intotensorflow:masterfrom
llukito:fix/mobilenet-v3-numpy-deprecation
Feb 13, 2026
Merged

fix(research): replace deprecated np.int with int in mobilenet_v3#13609
marksandler2 merged 1 commit intotensorflow:masterfrom
llukito:fix/mobilenet-v3-numpy-deprecation

Conversation

@llukito
Copy link
Contributor

@llukito llukito commented Feb 13, 2026

Description

This PR fixes a compatibility issue with NumPy 1.24+ in the MobileNet V3 implementation.

The Problem:
NumPy 1.20 deprecated np.int, and NumPy 1.24 completely removed it. This causes an AttributeError: module 'numpy' has no attribute 'int' when _reduce_consecutive_layers is called (e.g., when building Minimalistic or EdgeTPU variants of MobileNetV3).

The Fix:
Replaced the removed np.int(...) with Python's built-in int(...).

Changes

  • Modified research/slim/nets/mobilenet/mobilenet_v3.py: Replaced np.int with int in the _reduce_consecutive_layers function.

Verification

  • Confirmed that num_outputs in conv_defs is strictly scalar, ensuring int() is the correct and safe replacement.
  • This change restores the ability to instantiate MobileNetV3 models in environments using modern NumPy versions.

The use of `np.int` was deprecated in NumPy 1.20 and completely 
removed in NumPy 1.24. This change caused `_reduce_consecutive_layers` 
to fail with an AttributeError when using NumPy 1.24+.

This commit replaces `np.int` with the built-in `int` function 
to ensure compatibility with modern NumPy versions. 

Affected file: research/slim/nets/mobilenet/mobilenet_v3.py
Copy link
Collaborator

@marksandler2 marksandler2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@marksandler2 marksandler2 merged commit b61e63a into tensorflow:master Feb 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants