Skip to content

Commit

Permalink
Talos Classification Test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbieker committed Feb 9, 2019
1 parent 7f1c32e commit 4699ca8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
60 changes: 33 additions & 27 deletions examples/talos_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,37 @@
# Parameter Dictionary for talos

params = {'lr': (1, 10, 50),
'first_neuron': [4, 8, 16, 32, 64, 128, 256],
'last_neuron': [4, 8, 16, 32, 64, 128, 256],
'hidden_layers': [2, 3, 4, 5, 6, 7, 8],
'batch_size': [2, 3, 4, 8, 16, 32],
'first_neuron': [4, 16, 32],
'last_neuron': [4, 8, 16],
'hidden_layers': [2, 3, 4],
'batch_size': [2, 8, 32],
'epochs': [500],
'dropout': (0, 0.80, 10),
'dropout': (0, 0.40, 5),
'weight_regulizer': [None],
'emb_output_dims': [None],
'optimizer': [adam, nadam, rmsprop, sgd],
'optimizer': [adam, nadam, rmsprop],
'losses': [categorical_crossentropy, logcosh],
'activation': [relu, elu],
'last_activation': [softmax],

'neuron_1': [4, 8, 16, 32, 64],
'kernel_1': [1, 2, 3, 4, 5],
'neuron_1': [8, 16, 32, 64],
'kernel_1': [1, 3, 5],
'stride_1': [1, 2, 3],
'rec_dropout': [0.0, 0.8, 40],
'rec_act': [relu, elu, hard_sigmoid, tanh, sigmoid],
'layer_drop': [0.0, 0.8, 40],
'pool': [0, 1],
'neuron_2': [4, 8, 16, 32, 64],
'kernel_2': [1, 2, 3],
'stride_2': [1, 2],
'three': [0, 1],
'neuron_3': [4, 8, 16, 32, 64],
'kernel_3': [1, 2, 3],
'stride_3': [1, 2],
}
'rec_dropout': [0.0, 0.4, 5],
'rec_act': [hard_sigmoid, tanh],
'layer_drop': [0.0, 0.4, 5],

}
'''
'pool': [0, 1],
'neuron_2': [4, 8, 16, 32, 64],
'kernel_2': [1, 2, 3],
'stride_2': [1, 2],
'three': [0, 1],
'neuron_3': [4, 8, 16, 32, 64],
'kernel_3': [1, 2, 3],
'stride_3': [1, 2],
'''

def input_model(x_train, y_train, x_val, y_val, params):
model = Sequential()
Expand All @@ -62,6 +64,7 @@ def input_model(x_train, y_train, x_val, y_val, params):
recurrent_activation=params['rec_act'],
return_sequences=False,
stateful=False))
'''
if params['pool']:
model.add(MaxPooling2D())
model.add(Conv2D(params['neuron_2'], kernel_size=params['kernel_2'], strides=params['stride_2'],
Expand All @@ -73,6 +76,7 @@ def input_model(x_train, y_train, x_val, y_val, params):
padding='same', activation=params['activation']))
model.add(MaxPooling2D())
model.add(Dropout(model.add('layer_drop')))
'''
model.add(Flatten())

hidden_layers(model, params, params['last_neuron'])
Expand All @@ -87,23 +91,25 @@ def input_model(x_train, y_train, x_val, y_val, params):
batch_size=params['batch_size'],
epochs=params['epochs'], verbose=0,
validation_data=[x_val, y_val],
callbacks=early_stopper(params['epochs'],
mode='moderate'))
callbacks=[early_stopper(params['epochs'],
mode='moderate')])

return out, model


directory = "/home/jacob/Documents/iact_events/"
gamma_dir = [directory + "gammaFeature/no_clean/"]
proton_dir = [directory + "protonFeature/no_clean/"]
directory = "/media/jacob/WDRed8TB1/Insync/iact_events/"
gamma_dir = [directory + "gamma/no_clean/"]
proton_dir = [directory + "proton/no_clean/"]

x, y = get_chunk_of_data(directory=gamma_dir, proton_directory=proton_dir, indicies=(30, 129, 5), rebin=75,
chunk_size=1500)
chunk_size=10000)
print("Got data")
print("X Shape", x.shape)
print("Y Shape", y.shape)
history = ta.Scan(x, y,
params=params,
dataset_name='separation_test',
experiment_no='1',
model=input_model,
search_method='random',
grid_downsample=0.5)
grid_downsample=0.001)
8 changes: 6 additions & 2 deletions factnn/utils/cross_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def get_chunk_of_data(directory, proton_directory="", indicies=(30,129,3),
train_gen, val_gen, test_gen, shape = data(start_slice=indicies[0], end_slice=indicies[1],
final_slices=indicies[2],
rebin_size=rebin, gamma_train=gamma_paths,
proton_train=proton_paths, batch_size=chunk_size,
proton_train=proton_paths, batch_size=1,
normalize=normalize,
model_type=model_type, as_channels=as_channels,
truncate=truncate,
Expand All @@ -257,7 +257,7 @@ def get_chunk_of_data(directory, proton_directory="", indicies=(30,129,3),
train_gen, val_gen, test_gen, shape = data(start_slice=indicies[0], end_slice=indicies[1],
final_slices=indicies[2],
rebin_size=rebin, gamma_train=gamma_paths,
batch_size=chunk_size, normalize=normalize,
batch_size=1, normalize=normalize,
model_type=model_type, as_channels=as_channels,
truncate=truncate,
dynamic_resize=dynamic_resize,
Expand All @@ -266,6 +266,10 @@ def get_chunk_of_data(directory, proton_directory="", indicies=(30,129,3),
return_features=return_features)

x, y = train_gen.__getitem__(0)
for i in range(1, chunk_size):
x_temp, y_temp = train_gen.__getitem__(i)
x = np.append(x, x_temp, axis=0)
y = np.append(y, y_temp, axis=0)

return x, y

Expand Down

0 comments on commit 4699ca8

Please sign in to comment.