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

Handle ColumnSchema target in serialization of SequenceTransform #1214

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
9 changes: 8 additions & 1 deletion merlin/models/tf/transforms/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ def compute_output_shape(self, input_shape):
def get_config(self):
"""Returns the config of the layer as a Python dictionary."""
config = super().get_config()
config["target"] = self.target
target = self.target
if isinstance(target, ColumnSchema):
target = schema_utils.schema_to_tensorflow_metadata_json(Schema([target]))
config["target"] = target

return config

Expand All @@ -193,6 +196,10 @@ def from_config(cls, config):
"""Creates layer from its config. Returning the instance."""
config = tf_utils.maybe_deserialize_keras_objects(config, ["pre", "post", "aggregation"])
config["schema"] = schema_utils.tensorflow_metadata_json_to_schema(config["schema"])
if config["target"].startswith("{"): # we have a schema
config["target"] = [
col for col in schema_utils.tensorflow_metadata_json_to_schema(config["target"])
][0]
schema = config.pop("schema")
target = config.pop("target")
return cls(schema, target, **config)
Expand Down
Loading