Functions | Variables
train_cnn_continue Namespace Reference

Functions

def load_model (name)
 
def save_model (model, name)
 

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.005, 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)
 
 h
 training ############################### More...
 
 score
 

Function Documentation

def train_cnn_continue.load_model (   name)

Definition at line 31 of file train_cnn_continue.py.

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

Definition at line 37 of file train_cnn_continue.py.

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

Variable Documentation

train_cnn_continue.args = parser.parse_args()

Definition at line 7 of file train_cnn_continue.py.

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

Definition at line 59 of file train_cnn_continue.py.

train_cnn_continue.cfg_name = args.model

Definition at line 51 of file train_cnn_continue.py.

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

Definition at line 54 of file train_cnn_continue.py.

train_cnn_continue.config = read_config(args.config)

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

Definition at line 49 of file train_cnn_continue.py.

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

Definition at line 89 of file train_cnn_continue.py.

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

Definition at line 92 of file train_cnn_continue.py.

train_cnn_continue.default

Definition at line 3 of file train_cnn_continue.py.

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

Definition at line 102 of file train_cnn_continue.py.

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

Definition at line 76 of file train_cnn_continue.py.

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

Definition at line 85 of file train_cnn_continue.py.

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

Definition at line 88 of file train_cnn_continue.py.

train_cnn_continue.h
Initial value:
1 = model.fit({'main_input': X_train},
2  {'em_trk_none_netout': EmTrkNone_train, 'michel_netout': Michel_train},
3  validation_data=(
4  {'main_input': X_test},
5  {'em_trk_none_netout': EmTrkNone_test, 'michel_netout': Michel_test}),
6  batch_size=batch_size, epochs=nb_epoch, shuffle=True,
7  verbose=1)

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

Definition at line 133 of file train_cnn_continue.py.

train_cnn_continue.help

Definition at line 3 of file train_cnn_continue.py.

train_cnn_continue.img_cols

Definition at line 57 of file train_cnn_continue.py.

train_cnn_continue.img_rows

Definition at line 57 of file train_cnn_continue.py.

train_cnn_continue.loss

Definition at line 70 of file train_cnn_continue.py.

train_cnn_continue.loss_weights

Definition at line 71 of file train_cnn_continue.py.

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

Definition at line 103 of file train_cnn_continue.py.

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

Definition at line 77 of file train_cnn_continue.py.

train_cnn_continue.model = load_model(cfg_name)

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

Definition at line 66 of file train_cnn_continue.py.

train_cnn_continue.n = dataY.shape[0]

Definition at line 93 of file train_cnn_continue.py.

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

Definition at line 100 of file train_cnn_continue.py.

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

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

Definition at line 74 of file train_cnn_continue.py.

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

Definition at line 61 of file train_cnn_continue.py.

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

Definition at line 60 of file train_cnn_continue.py.

int train_cnn_continue.ntot = 0

Definition at line 80 of file train_cnn_continue.py.

train_cnn_continue.optimizer

Definition at line 69 of file train_cnn_continue.py.

train_cnn_continue.out_name = args.output

Definition at line 52 of file train_cnn_continue.py.

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

Definition at line 2 of file train_cnn_continue.py.

train_cnn_continue.PATCH_SIZE_D

Definition at line 56 of file train_cnn_continue.py.

train_cnn_continue.PATCH_SIZE_W

Definition at line 56 of file train_cnn_continue.py.

train_cnn_continue.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 145 of file train_cnn_continue.py.

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

Definition at line 68 of file train_cnn_continue.py.

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

Definition at line 81 of file train_cnn_continue.py.

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

Definition at line 101 of file train_cnn_continue.py.

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

Definition at line 75 of file train_cnn_continue.py.