Functions
generator Namespace Reference

Functions

def produce_seq (batch_size, data, sample_ids)
 

Function Documentation

def generator.produce_seq (   batch_size,
  data,
  sample_ids 
)

Definition at line 7 of file generator.py.

References makeTrainCVSamples.int, and PandAna.Demos.demo1.range.

Referenced by make_training.train_model().

7 def produce_seq(batch_size, data, sample_ids):
8  while True:
9  sample_count = len(sample_ids)
10  batches = int(sample_count/batch_size)
11  left_samples = sample_count%batch_size
12  if left_samples:
13  batches = batches +1
14  for ids in range(0, batches):
15  if ids == batches-1:
16  batch_ids = sample_ids[ids*batch_size:]
17  else:
18  batch_ids = sample_ids[ids*batch_size:ids*batch_size+batch_size]
19  batch_ids = sorted(batch_ids)
20 
21  X = data['data'][batch_ids]
22  Y = data['label'][batch_ids]
23  X1,X2 = X[:, [0]], X[:, [1]]
24 
25  X1 = X1.reshape(X1.shape[0], 1, 100, 80).astype('float32')/255
26  X2 = X2.reshape(X2.shape[0], 1, 100, 80).astype('float32')/255
27  Y = np_utils.to_categorical(Y,5)
28 
29  yield {'input1':np.array(X1), 'input2':np.array(X2)} , { 'out':np.array(Y) }
30 
31 
def produce_seq(batch_size, data, sample_ids)
Definition: generator.py:7