Skip to content

Commit

Permalink
Improving docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielspmoreira committed Feb 6, 2023
1 parent 8d74073 commit 95cc7a5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions merlin/models/tf/core/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,11 @@ class SequenceAggregator(Block):
Args:
combiner: Optional[str]
Method to use for aggregation.
Accepts an str ("max", "min", "sum", "mean", "masked_mean").
Defaults to "mean"
Accepts an str ("max", "min", "sum", "mean", "masked_mean"). Defaults to "mean".
Note: "masked_mean" computes the mean of the specified axis considering only
masked values. It was originally created to ignore padded positions
on dense tensors representing sequences, but with RaggedTensor support
that can be done by just using regular TF mean aggregation.
axis: int
The dimensions to reduce.
Defaults to 1
Expand Down
21 changes: 21 additions & 0 deletions merlin/models/tf/inputs/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@

@tf.keras.utils.register_keras_serializable(package="merlin.models")
class Continuous(Filter):
"""Filters (keeps) only the continuous features.
Parameters
----------
inputs : Optional[Union[Sequence[str], Union[Schema, Tags]]], optional
Indicates how the continuous features should be identified to be filtered.
It accepts a schema, a column schema tag or a list with the feature names.
If None (default), it looks for columns with the CONTINUOUS tag in the
column schema.
"""

def __init__(
self, inputs: Optional[Union[Sequence[str], Union[Schema, Tags]]] = None, **kwargs
):
Expand All @@ -44,6 +55,16 @@ def ContinuousProjection(
schema: Schema,
projection: tf.keras.layers.Layer,
) -> SequentialBlock:
"""Concatenates the continuous features and combines them
using a layer
Parameters
----------
schema : Schema
Schema that includes the continuous features
projection : tf.keras.layers.Layer
Layer that will be used to combine the continuous features
"""
return SequentialBlock(Continuous(schema, aggregation="concat"), projection)


Expand Down

0 comments on commit 95cc7a5

Please sign in to comment.