-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreproc.py
More file actions
31 lines (26 loc) · 789 Bytes
/
Copy pathpreproc.py
File metadata and controls
31 lines (26 loc) · 789 Bytes
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
import random
def get_index_generator(size):
"""
Creates generator for generating indexes of the dataset of 3D models, in random order. It will randomly shuffle
a list of ints from 0 to size-1, then return one of the numbers at each iteration, until it runs out, and shuffles
the numbers again, and so on.
Parameters
----------
size : int
Number of 3D models in the dataset.
Returns
-------
tensor
The output tensor.
"""
perm = list(range(size))
random.shuffle(perm)
index = 0
while True:
# check if it has reached the end of the epoch
if index >= size:
index = 0
perm = list(range(size))
random.shuffle(perm)
yield perm[index]
index += 1