Skip to content

Commit bdfe6a7

Browse files
authored
Change Hparams keras test to be compatible internally (#6773)
#6759 modified _keras_test.py to work with Keras 3 but it did not import correctly into the internal repository. It was therefore reverted in #6767. This changes the test to work both in the oss and internal repos. Googlers, see cl/612511563 for sample import results.
1 parent 0c5523f commit bdfe6a7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tensorboard/plugins/hparams/_keras_test.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from unittest import mock
1919

2020
from google.protobuf import text_format
21+
import numpy as np
2122
import tensorflow as tf
2223

2324
from tensorboard.plugins.hparams import _keras
@@ -150,19 +151,18 @@ def test_explicit_writer(self):
150151
# We'll assume that the contents are correct, as in the case where
151152
# the file writer was constructed implicitly.
152153

153-
# def test_non_eager_failure(self):
154-
# with tf.compat.v1.Graph().as_default():
155-
# assert not tf.executing_eagerly()
156-
# self._initialize_model(writer=self.logdir)
157-
# with self.assertRaisesRegex(
158-
# RuntimeError, "only supported in TensorFlow eager mode"
159-
# ):
160-
# self.model.fit(
161-
# x=tf.constant([(1,)]),
162-
# y=tf.constant([(2,)]),
163-
# steps_per_epoch=1,
164-
# callbacks=[self.callback],
165-
# )
154+
def test_non_eager_failure(self):
155+
with tf.compat.v1.Graph().as_default():
156+
assert not tf.executing_eagerly()
157+
self._initialize_model(writer=self.logdir)
158+
with self.assertRaisesRegex(
159+
RuntimeError, "only supported in TensorFlow eager mode"
160+
):
161+
self.model.fit(
162+
x=np.ones((1,)),
163+
y=np.ones((1,)),
164+
callbacks=[self.callback],
165+
)
166166

167167
def test_reuse_failure(self):
168168
self._initialize_model(writer=self.logdir)

0 commit comments

Comments
 (0)