Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Fix Squeeze for channel first network creation (#178)
Browse files Browse the repository at this point in the history
The current efficientnet implementation does not work in channel first mode, because the reshape dimensions are hardcoded to channel last. This fix adds full channel first support
  • Loading branch information
andreABbauer authored Mar 31, 2020
1 parent b34c106 commit 0bb8618
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion keras_applications/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ def block(inputs, activation_fn=swish, drop_rate=0., name='',
if 0 < se_ratio <= 1:
filters_se = max(1, int(filters_in * se_ratio))
se = layers.GlobalAveragePooling2D(name=name + 'se_squeeze')(x)
se = layers.Reshape((1, 1, filters), name=name + 'se_reshape')(se)
if bn_axis == 1:
se = layers.Reshape((filters, 1, 1), name=name + 'se_reshape')(se)
else:
se = layers.Reshape((1, 1, filters), name=name + 'se_reshape')(se)
se = layers.Conv2D(filters_se, 1,
padding='same',
activation=activation_fn,
Expand Down

0 comments on commit 0bb8618

Please sign in to comment.