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

Update asserts to avoid deprecated methods #2053

Merged
merged 1 commit into from
Jan 21, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_config(self):
"vocabulary_size": self.vocabulary_size,
"unselectable_token_ids": unselectable_token_ids,
}
self.assertDictContainsSubset(expected_config, config)
self.assertEqual(config, {**config, **expected_config})

# Test cloned masked_lm_masker can be run.
cloned_masked_lm_masker = MaskedLMMaskGenerator.from_config(config)
Expand Down
4 changes: 2 additions & 2 deletions keras_hub/src/models/efficientnet/cba_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def test_same_input_output_shapes(self):
layer = CBABlock(input_filters=32, output_filters=32)

output = layer(inputs)
self.assertEquals(output.shape, (1, 64, 64, 32))
self.assertEqual(output.shape, (1, 64, 64, 32))
self.assertLen(output, 1)

def test_different_input_output_shapes(self):
inputs = keras.random.normal(shape=(1, 64, 64, 32), dtype="float32")
layer = CBABlock(input_filters=32, output_filters=48)

output = layer(inputs)
self.assertEquals(output.shape, (1, 64, 64, 48))
self.assertEqual(output.shape, (1, 64, 64, 48))
self.assertLen(output, 1)
12 changes: 6 additions & 6 deletions keras_hub/src/models/efficientnet/efficientnet_backbone_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,24 @@ def test_feature_pyramid_outputs(self):
height = width = 256
outputs = model(keras.ops.ones(shape=(batch_size, height, width, 3)))
levels = ["P1", "P2", "P3", "P4", "P5"]
self.assertEquals(list(outputs.keys()), levels)
self.assertEquals(
self.assertEqual(list(outputs.keys()), levels)
self.assertEqual(
outputs["P1"].shape,
(batch_size, height // 2**1, width // 2**1, 24),
)
self.assertEquals(
self.assertEqual(
outputs["P2"].shape,
(batch_size, height // 2**2, width // 2**2, 48),
)
self.assertEquals(
self.assertEqual(
outputs["P3"].shape,
(batch_size, height // 2**3, width // 2**3, 64),
)
self.assertEquals(
self.assertEqual(
outputs["P4"].shape,
(batch_size, height // 2**4, width // 2**4, 160),
)
self.assertEquals(
self.assertEqual(
outputs["P5"].shape,
(batch_size, height // 2**5, width // 2**5, 1280),
)
Expand Down
6 changes: 3 additions & 3 deletions keras_hub/src/models/efficientnet/fusedmbconv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def test_same_input_output_shapes(self):
layer = FusedMBConvBlock(input_filters=32, output_filters=32)

output = layer(inputs)
self.assertEquals(output.shape, (1, 64, 64, 32))
self.assertEqual(output.shape, (1, 64, 64, 32))
self.assertLen(output, 1)

def test_different_input_output_shapes(self):
inputs = keras.random.normal(shape=(1, 64, 64, 32), dtype="float32")
layer = FusedMBConvBlock(input_filters=32, output_filters=48)

output = layer(inputs)
self.assertEquals(output.shape, (1, 64, 64, 48))
self.assertEqual(output.shape, (1, 64, 64, 48))
self.assertLen(output, 1)

def test_squeeze_excitation_ratio(self):
Expand All @@ -28,5 +28,5 @@ def test_squeeze_excitation_ratio(self):
)

output = layer(inputs)
self.assertEquals(output.shape, (1, 64, 64, 48))
self.assertEqual(output.shape, (1, 64, 64, 48))
self.assertLen(output, 1)
6 changes: 3 additions & 3 deletions keras_hub/src/models/efficientnet/mbconv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ def test_same_input_output_shapes(self):
layer = MBConvBlock(input_filters=32, output_filters=32)

output = layer(inputs)
self.assertEquals(output.shape, (1, 64, 64, 32))
self.assertEqual(output.shape, (1, 64, 64, 32))
self.assertLen(output, 1)

def test_different_input_output_shapes(self):
inputs = keras.random.normal(shape=(1, 64, 64, 32), dtype="float32")
layer = MBConvBlock(input_filters=32, output_filters=48)

output = layer(inputs)
self.assertEquals(output.shape, (1, 64, 64, 48))
self.assertEqual(output.shape, (1, 64, 64, 48))
self.assertLen(output, 1)

def test_squeeze_excitation_ratio(self):
inputs = keras.random.normal(shape=(1, 64, 64, 32), dtype="float32")
layer = MBConvBlock(input_filters=32, output_filters=48, se_ratio=0.25)

output = layer(inputs)
self.assertEquals(output.shape, (1, 64, 64, 48))
self.assertEqual(output.shape, (1, 64, 64, 48))
self.assertLen(output, 1)
2 changes: 1 addition & 1 deletion keras_hub/src/tests/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def run_backbone_test(
# Check name maps to classname.
name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", cls.__name__)
name = re.sub("([a-z])([A-Z])", r"\1_\2", name).lower()
self.assertRegexpMatches(backbone.name, name)
self.assertRegex(backbone.name, name)

# Check mixed precision.
if run_mixed_precision_check:
Expand Down
Loading