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

Fix PyDatasetAdapterTest::test_class_weight test with Torch on GPU. #20665

Merged
merged 1 commit into from
Dec 19, 2024
Merged
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
5 changes: 2 additions & 3 deletions keras/src/trainers/data_adapters/py_dataset_adapter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,11 @@ def test_class_weight(self):
for index, batch in enumerate(gen):
# Batch is a tuple of (x, y, class_weight)
self.assertLen(batch, 3)
batch = [backend.convert_to_numpy(x) for x in batch]
# Let's verify the data and class weights match for each element
# of the batch (2 elements in each batch)
for sub_elem in range(2):
self.assertTrue(
np.array_equal(batch[0][sub_elem], x[index * 2 + sub_elem])
)
self.assertAllEqual(batch[0][sub_elem], x[index * 2 + sub_elem])
self.assertEqual(batch[1][sub_elem], y[index * 2 + sub_elem])
class_key = np.int32(batch[1][sub_elem])
self.assertEqual(batch[2][sub_elem], class_w[class_key])
Expand Down
Loading