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

Allow passing custom dataset adapters. #20349

Merged
merged 2 commits into from
Oct 14, 2024
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
2 changes: 1 addition & 1 deletion keras/src/layers/core/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def compute_mask(self, inputs, mask=None):
return ops.not_equal(inputs, 0)

def compute_output_shape(self, input_shape):
return input_shape + (self.output_dim,)
return (*input_shape, self.output_dim)

def enable_lora(
self, rank, a_initializer="he_uniform", b_initializer="zeros"
Expand Down
5 changes: 5 additions & 0 deletions keras/src/trainers/data_adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from keras.src.distribution import distribution_lib
from keras.src.trainers.data_adapters import array_data_adapter
from keras.src.trainers.data_adapters import data_adapter
from keras.src.trainers.data_adapters import py_dataset_adapter
from keras.src.trainers.data_adapters.array_data_adapter import ArrayDataAdapter
from keras.src.trainers.data_adapters.generator_data_adapter import (
Expand All @@ -23,6 +24,10 @@ def get_data_adapter(
shuffle=False,
class_weight=None,
):
# Allow passing a custom data adapter.
if isinstance(x, data_adapter.DataAdapter):
return x

# Check for multi-process/worker distribution. Since only tf.dataset
# is supported at the moment, we will raise error if the inputs fail
# the type check
Expand Down