Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion keras/src/applications/mobilenet_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,13 @@ def hard_swish(x):
def _depth(v, divisor=8, min_value=None):
if min_value is None:
min_value = divisor
new_v = max(min_value, int(v + divisor / 2) // divisor * divisor)
# Compute new_v without creating intermediate float; avoid float division
# by using integer math where possible
vd = int(v)
new_v = ((vd + divisor // 2) // divisor) * divisor
if new_v < min_value:
new_v = min_value
# Make sure that round down does not go down by more than 10%.
# Make sure that round down does not go down by more than 10%.
if new_v < 0.9 * v:
new_v += divisor
Expand Down