forked from google-research/t5x
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_seqio_dataset.py
More file actions
52 lines (45 loc) · 1.77 KB
/
test_seqio_dataset.py
File metadata and controls
52 lines (45 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import seqio
from t5x import utils
import tensorflow as tf
from ..gins import task
def main():
ds = utils.get_dataset(
utils.DatasetConfig(
"c4_prefix_lm_objective_decoder_architecture_with_bot_seperator",
task_feature_lengths={
"decoder_target_tokens": 626,
"decoder_input_tokens": 626,
"decoder_segment_ids": 626,
"decoder_causal_attention": 626,
"targets": 625 # we have to take in account an extra token between input and target
},
split="train",
batch_size=2048,
shuffle=False,
seed=None,
use_cached=True,
pack=True,
use_custom_packing_ops=False,
use_memory_cache=False,
),
0,
1,
seqio.PassThroughFeatureConverter,
)
first_element = next(iter(ds))
print(first_element)
# This should output `dict_keys(['decoder_target_tokens', 'decoder_input_tokens', 'decoder_loss_weights', 'decoder_segment_ids', 'decoder_positions'])`
print(first_element.keys())
print(first_element["decoder_target_tokens"])
print(first_element["decoder_loss_weights"])
# This should all output `tf.Tensor([2048 626], shape=(2,), dtype=int32)`
print(tf.shape(first_element["decoder_target_tokens"]))
print(tf.shape(first_element["decoder_input_tokens"]))
print(tf.shape(first_element["decoder_loss_weights"]))
# print(tf.shape(first_element["decoder_segment_ids"]))
# print(tf.shape(first_element["decoder_positions"]))
print(tf.where(first_element["decoder_target_tokens"] == 32000))
print(tf.where(first_element["decoder_input_tokens"] == 32000))
print(ds.element_spec)
if __name__ == "__main__":
main()