MCPcopy
hub / github.com/PaddlePaddle/PaddleFormers / apply

Method apply

paddleformers/data/sampler.py:89–103  ·  view source on GitHub ↗
(self, fn)

Source from the content-addressed store, hash-verified

87 self._length = length
88
89 def apply(self, fn):
90 # Transformation functions would be performed. It includes
91 # :meth:`shuffle`, :meth:`sort`, :meth:`fit` and :meth:`shard`.
92 # Args:
93 # fn (callable): Transformation functions to be performed.
94 # Returns:
95 # SamplerHelper: A new transformed :class:`SamplerHelper` object.
96
97 rs = fn(self)
98 if isinstance(rs, (list, tuple)):
99 iterable, data_source = rs
100 else:
101 iterable, data_source = rs, self.data_source
102 sampler = type(self)(data_source, iterable)
103 return sampler
104
105 def shuffle(self, buffer_size=-1, seed=None):
106 """

Calls 1

fnFunction · 0.50