Sequence
int64
1
25.2k
Time
int64
1
858M
File
stringclasses
830 values
RangeOffset
int64
0
2.21M
RangeLength
int64
0
168k
Text
stringlengths
1
4.7M
Language
stringclasses
20 values
Type
stringclasses
9 values
42
239,395
utils/dataloader_new.py
10
0
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"\n
python
content
43
240,218
utils/dataloader_new.py
24
0
null
python
selection_command
44
241,617
utils/dataloader_new.py
10
0
null
python
selection_command
45
248,430
utils/dataloader_new.py
10
0
\n
python
content
46
248,431
utils/dataloader_new.py
10
41
null
python
content
47
260,171
utils/dataloader_new.py
10
0
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
python
content
48
261,459
utils/dataloader_new.py
10
0
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"\n
python
content
49
261,460
utils/dataloader_new.py
51
41
null
python
content
50
288,363
utils/dataloader_new.py
0
0
null
python
tab
51
299,000
utils/dataloader_new.py
2,455
0
null
python
selection_mouse
52
299,161
utils/dataloader_new.py
2,451
23
get_all_episode_lengths
python
selection_mouse
53
301,860
utils/dataloader_new.py
2,466
0
null
python
selection_mouse
54
308,526
utils/dataloader_new.py
5,504
0
null
python
selection_mouse
55
308,702
utils/dataloader_new.py
5,496
15
episode_lengths
python
selection_mouse
56
313,137
utils/dataloader_new.py
5,830
0
null
python
selection_mouse
57
324,249
utils/dataloader_new.py
3,002
0
null
python
selection_mouse
58
324,387
utils/dataloader_new.py
2,991
18
make_epoch_indices
python
selection_mouse
59
381,882
TERMINAL
0
0
bash
null
terminal_focus
60
392,727
TERMINAL
0
0
cp utils/dataloader.py utils/dataloader_new.py
null
terminal_command
61
392,750
TERMINAL
0
0
\r\n[?2004l\r]633;E;cp utils/dataloader.py utils/dataloader_new.py;7e8119c7-7b99-4b0c-870d-b0c10112015b]633;C
null
terminal_output
62
392,947
utils/dataloader_new.py
0
7,264
import functools\nimport jax\n\nimport tensorflow as tf\n\n# reserve GPU memory for JAX only if tensorflow is built with GPU support\ntry:\n tf.config.experimental.set_visible_devices([], "GPU")\nexcept tf.errors.NotFoundError:\n pass\n\n\n# --- TensorFlow function for processing: slicing, normalization ---\ndef _tf_process_episode(episode_tensor, seq_len, image_h, image_w, image_c):\n """\n Processes a raw episode tensor in TensorFlow.\n Takes a full episode, extracts a random sequence, and normalizes it.\n Args:\n episode_tensor: A TensorFlow tensor representing a full video episode.\n Expected shape: (dynamic_length, image_h, image_w, image_c)\n Expected dtype: e.g., tf.uint8 (raw pixel values)\n seq_len: The desired length of the sub-sequence to extract.\n image_h: The height of each frame.\n image_w: The width of each frame.\n image_c: The number of channels in each frame.\n Returns:\n A TensorFlow tensor representing the processed video sequence.\n Shape: (seq_len, image_h, image_w, image_c)\n Dtype: tf.float32 (normalized pixel values)\n """\n current_episode_len = tf.shape(episode_tensor)[0]\n\n max_start_idx = current_episode_len - seq_len\n\n start_idx = tf.random.uniform(\n shape=(), minval=0, maxval=max_start_idx + 1, dtype=tf.int32\n )\n\n seq = episode_tensor[start_idx : start_idx + seq_len]\n\n seq = tf.cast(seq, tf.float32) / 255.0\n\n # Ensure the final shape is statically known for batching.\n # tf.reshape is robust, but tf.ensure_shape or set_shape can also be used if confident.\n processed_sequence = tf.reshape(seq, [seq_len, image_h, image_w, image_c])\n\n return processed_sequence\n\n\ndef _parse_tfrecord_fn(example_proto, image_h, image_w, image_c):\n feature_description = {\n "height": tf.io.FixedLenFeature([], tf.int64),\n "width": tf.io.FixedLenFeature([], tf.int64),\n "channels": tf.io.FixedLenFeature([], tf.int64),\n "sequence_length": tf.io.FixedLenFeature([], tf.int64),\n "raw_video": tf.io.FixedLenFeature([], tf.string),\n }\n example = tf.io.parse_single_example(example_proto, feature_description)\n\n video_shape = (example["sequence_length"], image_h, image_w, image_c)\n\n episode_tensor = tf.io.decode_raw(example["raw_video"], out_type=tf.uint8)\n episode_tensor = tf.reshape(episode_tensor, video_shape)\n\n episode_tensor = tf.ensure_shape(episode_tensor, [None, image_h, image_w, image_c])\n return episode_tensor\n\n\ndef get_dataloader(\n tfrecord_paths: list[str], # List of TFRecord file paths\n seq_len: int,\n global_batch_size: int,\n image_h: int,\n image_w: int,\n image_c: int,\n shuffle_buffer_size: int = 10,\n num_parallel_calls: int = tf.data.AUTOTUNE,\n seed: int = 42,\n):\n """\n Creates a tf.data.Dataset pipeline from TFRecord files.\n """\n if not tfrecord_paths:\n raise ValueError("tfrecord_paths list cannot be empty.")\n\n process_id = jax.process_index()\n num_processes = jax.process_count()\n\n assert (\n global_batch_size % num_processes == 0\n ), "Global batch size {global_batch_size} \\n must be divisible by the number of JAX processes {num_processes} for proper sharding."\n per_process_batch_size = global_batch_size // num_processes\n\n # Create a dataset of just the paths (filenames)\n path_dataset = tf.data.Dataset.from_tensor_slices(tfrecord_paths)\n breakpoint()\n\n dataset = tf.data.TFRecordDataset(\n tfrecord_paths, num_parallel_reads=tf.data.AUTOTUNE\n )\n\n dataset = dataset.shard(num_shards=num_processes, index=process_id)\n\n # (f.srambical) NOTE: For TFRecords, it's often good to have a large shuffle buffer.\n if shuffle_buffer_size > 0:\n dataset = dataset.shuffle(\n buffer_size=shuffle_buffer_size, seed=seed, reshuffle_each_iteration=True\n )\n parse_fn = functools.partial(\n _parse_tfrecord_fn, image_h=image_h, image_w=image_w, image_c=image_c\n )\n dataset = dataset.map(parse_fn, num_parallel_calls=num_parallel_calls)\n\n tf_process_fn = functools.partial(\n _tf_process_episode,\n seq_len=seq_len,\n image_h=image_h,\n image_w=image_w,\n image_c=image_c,\n )\n dataset = dataset.map(tf_process_fn, num_parallel_calls=num_parallel_calls)\n\n dataset = dataset.repeat(None)\n dataset = dataset.batch(per_process_batch_size, drop_remainder=True)\n dataset = dataset.prefetch(tf.data.AUTOTUNE)\n\n return dataset.as_numpy_iterator()\n
python
content
63
393,762
utils/dataloader_new.py
3,345
0
null
python
selection_mouse
64
393,788
utils/dataloader_new.py
3,344
0
null
python
selection_command
65
442,624
utils/dataloader_new.py
3,186
0
null
python
selection_mouse
66
442,661
utils/dataloader_new.py
3,185
0
null
python
selection_command
67
443,222
utils/dataloader_new.py
3,233
0
null
python
selection_command
68
443,416
utils/dataloader_new.py
3,328
0
null
python
selection_command
69
443,794
utils/dataloader_new.py
3,233
0
null
python
selection_command
70
443,918
utils/dataloader_new.py
3,185
0
null
python
selection_command
71
444,119
utils/dataloader_new.py
3,137
0
null
python
selection_command
72
444,619
utils/dataloader_new.py
3,090
0
null
python
selection_command
73
444,643
utils/dataloader_new.py
3,078
0
null
python
selection_command
74
444,682
utils/dataloader_new.py
3,076
0
null
python
selection_command
75
444,717
utils/dataloader_new.py
3,036
0
null
python
selection_command
76
444,752
utils/dataloader_new.py
3,000
0
null
python
selection_command
77
444,788
utils/dataloader_new.py
2,981
0
null
python
selection_command
78
444,824
utils/dataloader_new.py
2,933
0
null
python
selection_command
79
444,893
utils/dataloader_new.py
2,906
0
null
python
selection_command
80
444,931
utils/dataloader_new.py
2,886
0
null
python
selection_command
81
444,932
utils/dataloader_new.py
2,838
0
null
python
selection_command
82
444,968
utils/dataloader_new.py
2,830
0
null
python
selection_command
83
444,968
utils/dataloader_new.py
2,827
0
null
python
selection_command
84
445,004
utils/dataloader_new.py
2,807
0
null
python
selection_command
85
445,035
utils/dataloader_new.py
2,759
0
null
python
selection_command
86
445,036
utils/dataloader_new.py
2,724
0
null
python
selection_command
87
445,067
utils/dataloader_new.py
2,706
0
null
python
selection_command
88
445,099
utils/dataloader_new.py
2,688
0
null
python
selection_command
89
445,260
utils/dataloader_new.py
2,670
0
null
python
selection_command
90
445,433
utils/dataloader_new.py
2,642
0
null
python
selection_command
91
445,589
utils/dataloader_new.py
2,610
0
null
python
selection_command
92
445,768
utils/dataloader_new.py
2,562
0
null
python
selection_command
93
446,149
utils/dataloader_new.py
2,610
0
null
python
selection_command
94
446,527
utils/dataloader_new.py
2,642
0
null
python
selection_command
95
447,795
utils/dataloader_new.py
2,670
0
null
python
selection_command
96
448,304
utils/dataloader_new.py
2,688
0
null
python
selection_command
97
448,337
utils/dataloader_new.py
2,706
0
null
python
selection_command
98
448,381
utils/dataloader_new.py
2,724
0
null
python
selection_command
99
448,417
utils/dataloader_new.py
2,759
0
null
python
selection_command
100
448,533
utils/dataloader_new.py
2,807
0
null
python
selection_command
101
448,955
utils/dataloader_new.py
2,759
0
null
python
selection_command
102
450,467
utils/dataloader_new.py
2,758
0
null
python
selection_command
103
450,733
utils/dataloader_new.py
2,757
0
null
python
selection_command
104
450,886
utils/dataloader_new.py
2,756
0
null
python
selection_command
105
451,072
utils/dataloader_new.py
2,757
0
null
python
selection_command
106
451,307
utils/dataloader_new.py
2,758
0
null
python
selection_command
107
451,508
utils/dataloader_new.py
2,757
0
null
python
selection_command
108
451,619
utils/dataloader_new.py
2,758
0
null
python
selection_command
109
451,711
utils/dataloader_new.py
2,757
0
null
python
selection_command
110
451,843
utils/dataloader_new.py
2,758
0
null
python
selection_command
111
451,921
utils/dataloader_new.py
2,757
0
null
python
selection_command
112
452,028
utils/dataloader_new.py
2,758
0
null
python
selection_command
113
452,111
utils/dataloader_new.py
2,757
0
null
python
selection_command
114
452,239
utils/dataloader_new.py
2,758
0
null
python
selection_command
115
452,316
utils/dataloader_new.py
2,757
0
null
python
selection_command
116
452,444
utils/dataloader_new.py
2,758
0
null
python
selection_command
117
452,523
utils/dataloader_new.py
2,757
0
null
python
selection_command
118
452,666
utils/dataloader_new.py
2,758
0
null
python
selection_command
119
452,743
utils/dataloader_new.py
2,757
0
null
python
selection_command
120
452,867
utils/dataloader_new.py
2,758
0
null
python
selection_command
121
452,957
utils/dataloader_new.py
2,757
0
null
python
selection_command
122
453,062
utils/dataloader_new.py
2,758
0
null
python
selection_command
123
453,139
utils/dataloader_new.py
2,757
0
null
python
selection_command
124
453,381
utils/dataloader_new.py
2,792
0
null
python
selection_command
125
453,893
utils/dataloader_new.py
2,827
0
null
python
selection_command
126
453,904
utils/dataloader_new.py
2,830
0
null
python
selection_command
127
453,942
utils/dataloader_new.py
2,838
0
null
python
selection_command
128
454,028
utils/dataloader_new.py
2,871
0
null
python
selection_command
129
454,029
utils/dataloader_new.py
2,906
0
null
python
selection_command
130
454,071
utils/dataloader_new.py
2,933
0
null
python
selection_command
131
454,106
utils/dataloader_new.py
2,966
0
null
python
selection_command
132
454,139
utils/dataloader_new.py
3,000
0
null
python
selection_command
133
454,171
utils/dataloader_new.py
3,032
0
null
python
selection_command
134
454,213
utils/dataloader_new.py
3,069
0
null
python
selection_command
135
454,244
utils/dataloader_new.py
3,078
0
null
python
selection_command
136
454,247
utils/dataloader_new.py
3,090
0
null
python
selection_command
137
454,248
utils/dataloader_new.py
3,123
0
null
python
selection_command
138
454,285
utils/dataloader_new.py
3,170
0
null
python
selection_command
139
454,316
utils/dataloader_new.py
3,218
0
null
python
selection_command
140
454,350
utils/dataloader_new.py
3,313
0
null
python
selection_command
141
454,382
utils/dataloader_new.py
3,346
0
null
python
selection_command