MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / DataFromList

Class DataFromList

tensorpack/dataflow/raw.py:70–93  ·  view source on GitHub ↗

Wrap a list of datapoints to a DataFlow

Source from the content-addressed store, hash-verified

68
69
70class DataFromList(RNGDataFlow):
71 """ Wrap a list of datapoints to a DataFlow"""
72
73 def __init__(self, lst, shuffle=True):
74 """
75 Args:
76 lst (list): input list. Each element is a datapoint.
77 shuffle (bool): shuffle data.
78 """
79 super(DataFromList, self).__init__()
80 self.lst = lst
81 self.shuffle = shuffle
82
83 def __len__(self):
84 return len(self.lst)
85
86 def __iter__(self):
87 if not self.shuffle:
88 yield from self.lst
89 else:
90 idxs = np.arange(len(self.lst))
91 self.rng.shuffle(idxs)
92 for k in idxs:
93 yield self.lst[k]
94
95
96class DataFromGenerator(DataFlow):

Callers 2

get_train_dataflowFunction · 0.90
loadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected