Skip to content

Commit 8124a67

Browse files
committed
Adding doc-string to sample_from
1 parent 519159b commit 8124a67

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

merlin/models/torch/batch.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,29 @@ def sample_from(
134134
batch_size: int = 32,
135135
shuffle: Optional[bool] = False,
136136
) -> "Batch":
137+
"""Sample a batch from a dataset or a loader.
138+
139+
Example usage::
140+
dataset = merlin.io.Dataset(...)
141+
batch = Batch.sample_from(dataset)
142+
143+
Parameters
144+
----------
145+
dataset_or_loader: merlin.io.dataset
146+
A Dataset object or a Loader object.
147+
batch_size: int, default=32
148+
Number of samples to return.
149+
shuffle: bool
150+
Whether to sample a random batch or not, by default False.
151+
152+
Returns:
153+
-------
154+
features: Dict[torch.Tensor]
155+
dictionary of feature tensors.
156+
targets: Dict[torch.Tensor]
157+
dictionary of target tensors.
158+
"""
159+
137160
return sample_batch(dataset_or_loader, batch_size, shuffle)
138161

139162
def replace(

0 commit comments

Comments
 (0)