Skip to content
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
2 changes: 1 addition & 1 deletion smdebug/tensorflow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def get_layer_call_fn(layer: tf.keras.layers.Layer) -> Callable[[tf.Tensor], tf.

def call(inputs, *args, **kwargs) -> tf.Tensor:
layer_input = inputs
layer_output = old_call_fn(inputs)
layer_output = old_call_fn(inputs, *args, **kwargs)
for hook in layer._hooks:
hook_result = hook(inputs, layer_input=layer_input, layer_output=layer_output)
if hook_result is not None:
Expand Down
13 changes: 11 additions & 2 deletions tests/tensorflow2/test_model_subclassing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ def __init__(self):
self.conv1 = Conv2D(
32, 3, activation="relu", kernel_initializer=tf.keras.initializers.GlorotNormal(seed=12)
)
self.original_call = self.conv1.call

def new_call(inputs, *args, **kwargs):
# Since we use layer wrapper we need to assert if these parameters
# are actually being passed into the original call fn
assert kwargs["input_one"] == 1
kwargs.pop("input_one")
return self.original_call(inputs, *args, **kwargs)

self.conv1.call = new_call
self.conv0 = Conv2D(
32, 3, activation="relu", kernel_initializer=tf.keras.initializers.GlorotNormal(seed=12)
)
Expand All @@ -26,8 +36,7 @@ def __init__(self):
def first(self, x):
with tf.name_scope("first"):
tf.print("mymodel.first")
x = self.conv1(x)
# x = self.bn(x)
x = self.conv1(x, input_one=1)
return self.flatten(x)

def second(self, x):
Expand Down