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
10 changes: 5 additions & 5 deletions smdebug/tensorflow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,19 @@ def __init__(self):
self.layer_input = None
self.layer_output = None

def __call__(self, callable_inputs, *args, **kwargs) -> None:
def __call__(self, inputs, *args, **kwargs) -> None:
self.layer_input = kwargs["layer_input"]
self.layer_output = kwargs["layer_output"]


def get_layer_call_fn(layer: tf.keras.layers.Layer) -> Callable[[tf.Tensor], tf.Tensor]:
old_call_fn = layer.call

def call(callable_inputs, *args, **kwargs) -> tf.Tensor:
layer_input = callable_inputs
layer_output = old_call_fn(callable_inputs)
def call(inputs, *args, **kwargs) -> tf.Tensor:
layer_input = inputs
layer_output = old_call_fn(inputs)
for hook in layer._hooks:
hook_result = hook(callable_inputs, layer_input=layer_input, layer_output=layer_output)
hook_result = hook(inputs, layer_input=layer_input, layer_output=layer_output)
if hook_result is not None:
layer_output = hook_result
return layer_output
Expand Down
3 changes: 3 additions & 0 deletions tests/tensorflow2/test_keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def helper_keras_fit(
elif step == "predict":
model.predict(x_test[:100], callbacks=hooks, verbose=0)

model.save(trial_dir, save_format="tf")

hook.close()


Expand Down Expand Up @@ -180,6 +182,7 @@ def helper_keras_gradtape(
)
train_acc_metric.reset_states()

model.save(trial_dir, save_format="tf")
hook.close()


Expand Down