|
def | __init__ (self, cells=500, planes=500, views=3, batch_size=32, branches=True, outputs=7, standardize=True, images_path='/', shuffle=True, test_values=[]) |
|
def | generate (self, labels, list_IDs, yield_labels=True) |
|
def | sparsify1 (self, y) |
|
def | sparsify2 (self, y) |
|
def | sparsify3 (self, y) |
|
def | normalize (self, value, obj) |
|
def | sparsify5 (self, y) |
|
def | sparsify7 (self, y) |
|
Definition at line 13 of file data_generator.py.
def data_generator.DataGenerator.__init__ |
( |
|
self, |
|
|
|
cells = 500 , |
|
|
|
planes = 500 , |
|
|
|
views = 3 , |
|
|
|
batch_size = 32 , |
|
|
|
branches = True , |
|
|
|
outputs = 7 , |
|
|
|
standardize = True , |
|
|
|
images_path = '/' , |
|
|
|
shuffle = True , |
|
|
|
test_values = [] |
|
) |
| |
Definition at line 21 of file data_generator.py.
21 outputs=7, standardize=
True, images_path =
'/', shuffle=
True, test_values=[]):
def data_generator.DataGenerator.__data_generation |
( |
|
self, |
|
|
|
labels, |
|
|
|
list_IDs_temp, |
|
|
|
yield_labels |
|
) |
| |
|
private |
Definition at line 85 of file data_generator.py.
86 'Generates data of batch_size samples' 93 for view
in range(self.
views):
109 with
open(self.
images_path +
'/' + ID.split(
'.')[0].lstrip(
'a') +
'/images/' + ID +
'.gz',
'rb')
as image_file:
110 pixels = np.fromstring(zlib.decompress(image_file.read()), dtype=np.uint8, sep=
'').reshape(self.
views, self.
planes, self.
cells)
115 pixels = pixels.astype(
'float32')
120 for view
in range(self.
views):
121 X[view][i, :, :, :] = pixels[view, :, :].reshape(self.
planes, self.
cells, 1)
123 pixels = np.rollaxis(pixels, 0, 3)
124 X[i, :, :, :] = pixels
134 with
open(self.
images_path +
'/' + ID.split(
'.')[0].lstrip(
'a') +
'/info/' + ID +
'.info',
'rb')
as info_file:
135 energy_values = info_file.readlines()
136 self.test_values.append({
'y_value':y_value,
137 'fNuEnergy':
float(energy_values[1]),
138 'fLepEnergy':
float(energy_values[2]),
139 'fRecoNueEnergy':
float(energy_values[3]),
140 'fRecoNumuEnergy':
float(energy_values[4]),
141 'fEventWeight':
float(energy_values[5])})
int open(const char *, int)
Opens a file descriptor.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def __data_generation(self, labels, list_IDs_temp, yield_labels)
def data_generator.DataGenerator.__get_exploration_order |
( |
|
self, |
|
|
|
list_IDs |
|
) |
| |
|
private |
Definition at line 70 of file data_generator.py.
71 'Generates order of exploration' 74 indexes = np.arange(len(list_IDs))
77 np.random.shuffle(indexes)
def __get_exploration_order(self, list_IDs)
def data_generator.DataGenerator.generate |
( |
|
self, |
|
|
|
labels, |
|
|
|
list_IDs, |
|
|
|
yield_labels = True |
|
) |
| |
Definition at line 37 of file data_generator.py.
37 def generate(self, labels, list_IDs, yield_labels=True):
38 'Generates batches of samples'
def generate(self, labels, list_IDs, yield_labels=True)
def __get_exploration_order(self, list_IDs)
def __data_generation(self, labels, list_IDs_temp, yield_labels)
def data_generator.DataGenerator.normalize |
( |
|
self, |
|
|
|
value, |
|
|
|
obj |
|
) |
| |
Definition at line 204 of file data_generator.py.
205 if value == -1
or obj.size == 1:
def normalize(self, value, obj)
def data_generator.DataGenerator.sparsify1 |
( |
|
self, |
|
|
|
y |
|
) |
| |
Definition at line 161 of file data_generator.py.
162 'Returns labels in binary NumPy array' 163 return np.array([[1
if y[i] == j
else 1
if y[i]-1 == j
and j == 12
else 0
for j
in range(13)]
for i
in range(y.shape[0])])
def data_generator.DataGenerator.sparsify2 |
( |
|
self, |
|
|
|
y |
|
) |
| |
Definition at line 165 of file data_generator.py.
166 'Returns labels in binary NumPy array' 168 res[0] = np.zeros((y.shape[0], 4), dtype=int)
169 res[1] = np.zeros((y.shape[0], 4), dtype=int)
171 for i
in range(y.shape[0]):
173 res[0][i][(y[i] // 4)] = 1
174 res[1][i][(y[i] % 4)] = 1
177 res[1][i] = [-1, -1, -1, -1]
def data_generator.DataGenerator.sparsify3 |
( |
|
self, |
|
|
|
y |
|
) |
| |
Definition at line 181 of file data_generator.py.
182 'Returns labels in binary NumPy array' 184 res[0] = np.zeros((y.shape[0], 1), dtype=int)
185 res[1] = np.zeros((y.shape[0], 4), dtype=int)
186 res[2] = np.zeros((y.shape[0], 4), dtype=int)
188 for i
in range(y.shape[0]):
189 quotient = y[i] // 13
195 res[1][i][(y[i] // 4)] = 1
196 res[2][i][(y[i] % 4)] = 1
200 res[2][i] = [-1, -1, -1, -1]
def data_generator.DataGenerator.sparsify5 |
( |
|
self, |
|
|
|
y |
|
) |
| |
Definition at line 210 of file data_generator.py.
211 'Returns labels in binary NumPy array' 214 for i
in range(0,len(res)):
215 res[i] = np.zeros((y.shape[0], 4), dtype=int)
217 for i
in range(y.shape[0]):
218 for j
in range(len(res)):
def normalize(self, value, obj)
def data_generator.DataGenerator.sparsify7 |
( |
|
self, |
|
|
|
y |
|
) |
| |
Definition at line 223 of file data_generator.py.
224 'Returns labels in binary NumPy array' 226 res[0] = np.zeros((y.shape[0], 1), dtype=int)
228 for i
in range(1,len(res)):
229 res[i] = np.zeros((y.shape[0], 4), dtype=int)
231 for i
in range(y.shape[0]):
232 for j
in range(len(res)):
236
def normalize(self, value, obj)
data_generator.DataGenerator.batch_size |
data_generator.DataGenerator.branches |
data_generator.DataGenerator.cells |
data_generator.DataGenerator.images_path |
data_generator.DataGenerator.outputs |
data_generator.DataGenerator.planes |
data_generator.DataGenerator.shuffle |
data_generator.DataGenerator.standardize |
data_generator.DataGenerator.test_values |
data_generator.DataGenerator.views |
The documentation for this class was generated from the following file: