Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove forward slashes from layer names for backbones #2037

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions keras_cv/models/backbones/densenet/densenet_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ def __init__(
x = keras.layers.Rescaling(1 / 255.0)(x)

x = keras.layers.Conv2D(
64, 7, strides=2, use_bias=False, padding="same", name="conv1/conv"
64, 7, strides=2, use_bias=False, padding="same", name="conv1_conv"
)(x)
x = keras.layers.BatchNormalization(
axis=BN_AXIS, epsilon=BN_EPSILON, name="conv1/bn"
axis=BN_AXIS, epsilon=BN_EPSILON, name="conv1_bn"
)(x)
x = keras.layers.Activation("relu", name="conv1/relu")(x)
x = keras.layers.Activation("relu", name="conv1_relu")(x)
x = keras.layers.MaxPooling2D(
3, strides=2, padding="same", name="pool1"
)(x)
Expand Down
16 changes: 8 additions & 8 deletions keras_cv/models/backbones/mobilenet_v3/mobilenet_v3_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __init__(
axis=CHANNEL_AXIS,
epsilon=BN_EPSILON,
momentum=BN_MOMENTUM,
name="Conv/BatchNorm",
name="Conv_BatchNorm",
)(x)
x = apply_hard_swish(x)

Expand Down Expand Up @@ -161,7 +161,7 @@ def __init__(
axis=CHANNEL_AXIS,
epsilon=BN_EPSILON,
momentum=BN_MOMENTUM,
name="Conv_1/BatchNorm",
name="Conv_1_BatchNorm",
)(x)
x = apply_hard_swish(x)

Expand Down Expand Up @@ -291,11 +291,11 @@ def apply_inverted_res_block(
activation = keras.activations.get(activation)

shortcut = x
prefix = "expanded_conv/"
prefix = "expanded_conv_"
infilters = x.shape[CHANNEL_AXIS]

if expansion_index > 0:
prefix = f"expanded_conv_{expansion_index}/"
prefix = f"expanded_conv_{expansion_index}_"

x = keras.layers.Conv2D(
adjust_channels(infilters * expansion),
Expand All @@ -308,14 +308,14 @@ def apply_inverted_res_block(
axis=CHANNEL_AXIS,
epsilon=BN_EPSILON,
momentum=BN_MOMENTUM,
name=prefix + "expand/BatchNorm",
name=prefix + "expand_BatchNorm",
)(x)
x = activation(x)

if stride == 2:
x = keras.layers.ZeroPadding2D(
padding=utils.correct_pad_downsample(x, kernel_size),
name=prefix + "depthwise/pad",
name=prefix + "depthwise_pad",
)(x)

x = keras.layers.DepthwiseConv2D(
Expand All @@ -329,7 +329,7 @@ def apply_inverted_res_block(
axis=CHANNEL_AXIS,
epsilon=BN_EPSILON,
momentum=BN_MOMENTUM,
name=prefix + "depthwise/BatchNorm",
name=prefix + "depthwise_BatchNorm",
)(x)
x = activation(x)

Expand All @@ -353,7 +353,7 @@ def apply_inverted_res_block(
axis=CHANNEL_AXIS,
epsilon=BN_EPSILON,
momentum=BN_MOMENTUM,
name=prefix + "project/BatchNorm",
name=prefix + "project_BatchNorm",
)(x)

if stride == 1 and infilters == filters:
Expand Down
Loading