Skip to content

Commit

Permalink
add work-around to keras-team/keras#19796 in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsKue committed Jun 3, 2024
1 parent be6f65b commit 9a0fc43
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/utils/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def assert_layers_equal(layer1: keras.Layer, layer2: keras.Layer):
assert len(layer1.variables) == len(layer2.variables), f"Layers {layer1.name} and {layer2.name} have a different number of variables ({len(layer1.variables)}, {len(layer2.variables)})."
assert len(layer1.variables) > 0, f"Layers {layer1.name} and {layer2.name} have no variables."
for v1, v2 in zip(layer1.variables, layer2.variables):

if v1.name == "seed_generator_state" and v1.name == v2.name:
# keras issue: https://github.com/keras-team/keras/issues/19796
continue

v1 = keras.ops.convert_to_numpy(v1)
v2 = keras.ops.convert_to_numpy(v2)
assert keras.ops.all(keras.ops.isclose(v1, v2)), f"Variables for {layer1.name} and {layer2.name} are not equal: {v1} != {v2}"

0 comments on commit 9a0fc43

Please sign in to comment.