MCPcopy Create free account
hub / github.com/apple/axlearn / _text_ds

Function _text_ds

axlearn/common/input_tf_data_test.py:298–310  ·  view source on GitHub ↗
(texts: list[str], *, repeat=1)

Source from the content-addressed store, hash-verified

296
297
298def _text_ds(texts: list[str], *, repeat=1) -> tf.data.Dataset:
299 dataset = {
300 "text": [],
301 "index": [],
302 "is_valid": [],
303 }
304
305 for index, text in enumerate(texts):
306 dataset["index"].append(tf.constant(index, dtype=tf.int32))
307 dataset["text"].append(tf.constant(text, dtype=tf.string))
308 dataset["is_valid"].append(tf.constant(True, dtype=tf.bool))
309
310 return tf.data.Dataset.from_tensor_slices(dataset).repeat(repeat)
311
312
313def _tokens_ds(tokens: list[list[int]], *, repeat=1) -> tf.data.Dataset:

Calls

no outgoing calls

Tested by

no test coverage detected