Functions | Variables
train_cnn_continue_augmented_data Namespace Reference

Functions

def load_model (name)
 
def save_model (model, name)
 
def generate_data_generator (generator, X, Y1, Y2, b)
 

Variables

 parser = argparse.ArgumentParser(description='Run CNN training on patches with a few different hyperparameter sets.')
 
 help
 
 default
 
 args = parser.parse_args()
 
 config = read_config(args.config)
 configuration ############################# More...
 
 cfg_name = args.model
 
 out_name = args.output
 
 CNN_INPUT_DIR = config['training_on_patches']['input_dir']
 
 PATCH_SIZE_W
 
 PATCH_SIZE_D
 
 img_rows
 
 img_cols
 
 batch_size = config['training_on_patches']['batch_size']
 
 nb_epoch = config['training_on_patches']['nb_epoch']
 
 nb_classes = config['training_on_patches']['nb_classes']
 
 model = load_model(cfg_name)
 CNN commpilation ###########################. More...
 
 sgd = SGD(lr=0.002, decay=1e-5, momentum=0.9, nesterov=True)
 
 optimizer
 
 loss
 
 loss_weights
 
 n_training = count_events(CNN_INPUT_DIR, 'training')
 read data sets ############################ More...
 
 X_train = np.zeros((n_training, PATCH_SIZE_W, PATCH_SIZE_D, 1), dtype=np.float32)
 
 EmTrkNone_train = np.zeros((n_training, 3), dtype=np.int32)
 
 Michel_train = np.zeros((n_training, 1), dtype=np.int32)
 
int ntot = 0
 
list subdirs = [f for f in os.listdir(CNN_INPUT_DIR) if 'training' in f]
 
list filesX = [f for f in os.listdir(CNN_INPUT_DIR + '/' + dirname) if '_x.npy' in f]
 
 fnameY = fnameX.replace('_x.npy', '_y.npy')
 
 dataX = np.load(CNN_INPUT_DIR + '/' + dirname + '/' + fnameX)
 
 dataY = np.load(CNN_INPUT_DIR + '/' + dirname + '/' + fnameY)
 
 n = dataY.shape[0]
 
 n_testing = count_events(CNN_INPUT_DIR, 'testing')
 
 X_test = np.zeros((n_testing, PATCH_SIZE_W, PATCH_SIZE_D, 1), dtype=np.float32)
 
 EmTrkNone_test = np.zeros((n_testing, 3), dtype=np.int32)
 
 Michel_test = np.zeros((n_testing, 1), dtype=np.int32)
 
 datagen
 training ############################### More...
 
 h
 
 score
 

Function Documentation

def train_cnn_continue_augmented_data.generate_data_generator (   generator,
  X,
  Y1,
  Y2,
  b 
)

Definition at line 143 of file train_cnn_continue_augmented_data.py.

143 def generate_data_generator(generator, X, Y1, Y2, b):
144  genY1 = generator.flow(X, Y1, batch_size=b, seed=7)
145  genY2 = generator.flow(X, Y2, batch_size=b, seed=7)
146  while True:
147  g1 = genY1.next()
148  g2 = genY2.next()
149  yield {'main_input': g1[0]}, {'em_trk_none_netout': g1[1], 'michel_netout': g2[1]}
150 
def train_cnn_continue_augmented_data.load_model (   name)

Definition at line 32 of file train_cnn_continue_augmented_data.py.

32 def load_model(name):
33  with open(name + '_architecture.json') as f:
34  model = model_from_json(f.read())
35  model.load_weights(name + '_weights.h5')
36  return model
37 
int open(const char *, int)
Opens a file descriptor.
def train_cnn_continue_augmented_data.save_model (   model,
  name 
)

Definition at line 38 of file train_cnn_continue_augmented_data.py.

38 def save_model(model, name):
39  try:
40  with open(name + '_architecture.json', 'w') as f:
41  f.write(model.to_json())
42  model.save_weights(name + '_weights.h5', overwrite=True)
43  return True # Save successful
44  except:
45  return False # Save failed
46 
int open(const char *, int)
Opens a file descriptor.

Variable Documentation

train_cnn_continue_augmented_data.args = parser.parse_args()

Definition at line 7 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.batch_size = config['training_on_patches']['batch_size']

Definition at line 60 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.cfg_name = args.model

Definition at line 52 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.CNN_INPUT_DIR = config['training_on_patches']['input_dir']

Definition at line 55 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.config = read_config(args.config)

configuration #############################

Definition at line 50 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.datagen
Initial value:
1 = ImageDataGenerator(
2  featurewise_center=False, samplewise_center=False,
3  featurewise_std_normalization=False,
4  samplewise_std_normalization=False,
5  zca_whitening=False,
6  rotation_range=0, width_shift_range=0, height_shift_range=0,
7  horizontal_flip=True, # randomly flip images
8  vertical_flip=False)

training ###############################

Definition at line 133 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.dataX = np.load(CNN_INPUT_DIR + '/' + dirname + '/' + fnameX)

Definition at line 90 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.dataY = np.load(CNN_INPUT_DIR + '/' + dirname + '/' + fnameY)

Definition at line 93 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.default

Definition at line 3 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.EmTrkNone_test = np.zeros((n_testing, 3), dtype=np.int32)

Definition at line 103 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.EmTrkNone_train = np.zeros((n_training, 3), dtype=np.int32)

Definition at line 77 of file train_cnn_continue_augmented_data.py.

list train_cnn_continue_augmented_data.filesX = [f for f in os.listdir(CNN_INPUT_DIR + '/' + dirname) if '_x.npy' in f]

Definition at line 86 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.fnameY = fnameX.replace('_x.npy', '_y.npy')

Definition at line 89 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.h
Initial value:
1 = model.fit_generator(
2  generate_data_generator(datagen, X_train, EmTrkNone_train, Michel_train, b=batch_size),
3  validation_data=(
4  {'main_input': X_test},
5  {'em_trk_none_netout': EmTrkNone_test, 'michel_netout': Michel_test}),
6  steps_per_epoch=X_train.shape[0]/batch_size, epochs=nb_epoch,
7  verbose=1)

Definition at line 152 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.help

Definition at line 3 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.img_cols

Definition at line 58 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.img_rows

Definition at line 58 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.loss

Definition at line 71 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.loss_weights

Definition at line 72 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.Michel_test = np.zeros((n_testing, 1), dtype=np.int32)

Definition at line 104 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.Michel_train = np.zeros((n_training, 1), dtype=np.int32)

Definition at line 78 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.model = load_model(cfg_name)

CNN commpilation ###########################.

Definition at line 67 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.n = dataY.shape[0]

Definition at line 94 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.n_testing = count_events(CNN_INPUT_DIR, 'testing')

Definition at line 101 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.n_training = count_events(CNN_INPUT_DIR, 'training')

read data sets ############################

Definition at line 75 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.nb_classes = config['training_on_patches']['nb_classes']

Definition at line 62 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.nb_epoch = config['training_on_patches']['nb_epoch']

Definition at line 61 of file train_cnn_continue_augmented_data.py.

int train_cnn_continue_augmented_data.ntot = 0

Definition at line 81 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.optimizer

Definition at line 70 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.out_name = args.output

Definition at line 53 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.parser = argparse.ArgumentParser(description='Run CNN training on patches with a few different hyperparameter sets.')

Definition at line 2 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.PATCH_SIZE_D

Definition at line 57 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.PATCH_SIZE_W

Definition at line 57 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.score
Initial value:
1 = model.evaluate({'main_input': X_test},
2  {'em_trk_none_netout': EmTrkNone_test, 'michel_netout': Michel_test},
3  verbose=0)

Definition at line 164 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.sgd = SGD(lr=0.002, decay=1e-5, momentum=0.9, nesterov=True)

Definition at line 69 of file train_cnn_continue_augmented_data.py.

list train_cnn_continue_augmented_data.subdirs = [f for f in os.listdir(CNN_INPUT_DIR) if 'training' in f]

Definition at line 82 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.X_test = np.zeros((n_testing, PATCH_SIZE_W, PATCH_SIZE_D, 1), dtype=np.float32)

Definition at line 102 of file train_cnn_continue_augmented_data.py.

train_cnn_continue_augmented_data.X_train = np.zeros((n_training, PATCH_SIZE_W, PATCH_SIZE_D, 1), dtype=np.float32)

Definition at line 76 of file train_cnn_continue_augmented_data.py.