Exemplo n.º 1
0
# preload some data just to get the dimensions
data[0].objects['train']['singletons'].load(memory=False)
dims = data[0].objects['train']['singletons'].data.shape
dims = (
    None,
    3,
)
'''
first build the classifier!
'''

# set up data
variables = ['tau32', 'tau21', 'msd']
classifier_train_gen = obj.generateSingletons(data,
                                              variables,
                                              partition='train',
                                              batch=100)
classifier_validation_gen = obj.generateSingletons(data,
                                                   variables,
                                                   partition='validate',
                                                   batch=100)
classifier_test_gen = obj.generateSingletons(data,
                                             variables,
                                             partition='test',
                                             batch=1000)
test_i, test_o, test_w = next(classifier_test_gen)

inputs = Input(shape=(dims[1], ), name='input')
dense = Dense(32,
              activation='relu',
              name='dense1',
Exemplo n.º 2
0
              kernel_initializer='lecun_uniform')(inputs)
dense = Dense(10, activation='tanh', kernel_initializer='lecun_uniform')(dense)

category_pred = Dense(config.n_truth,
                      activation='softmax',
                      kernel_initializer='lecun_uniform')(dense)

classifier = Model(inputs=inputs, outputs=category_pred)
classifier.compile(optimizer=Adam(lr=0.001),
                   loss='categorical_crossentropy',
                   metrics=['accuracy'])

classifier.summary()

classifier_train_gen = obj.generateSingletons(data,
                                              partition='train',
                                              batch=1000)


def save_model(name='classifier'):
    classifier.save('%s.h5' % name)


def save_and_exit(signal=None, frame=None):
    save_model()
    flog.close()
    exit(1)


# ctrl+C now triggers a graceful exit
signal.signal(signal.SIGINT, save_and_exit)
Exemplo n.º 3
0
    coll = obj.PFSVCollection()
    coll.add_categories(['singletons'], fpath) 
    return coll 

top = make_coll('/data/t3serv014/snarayan/deep/v_deep_2/PARTITION/Top_*_CATEGORY.npy')
hig = make_coll('/data/t3serv014/snarayan/deep/v_deep_2/PARTITION/Higgs_*_CATEGORY.npy')
qcd = make_coll('/data/t3serv014/snarayan/deep/v_deep_2/PARTITION/QCD_*_CATEGORY.npy')

data = [top, hig, qcd]

'''
first build the classifier!
'''

# set up data 
classifier_train_gen = obj.generateSingletons(data, partition='train', batch=1000)
classifier_validation_gen = obj.generateSingletons(data, partition='validate', batch=10000)
classifier_test_gen = obj.generateSingletons(data, partition='validate', batch=10)
opts = {
        'decorr_mass' : DECORRMASS,
        'decorr_pt' : DECORRPT,
        'decorr_rho' : DECORRRHO,
        }
adv_train_gen = obj.generateSingletons(data, partition='train', batch=1000,**opts)
adv_validation_gen = obj.generateSingletons(data, partition='validate', batch=10000,**opts)
adv_test_gen = obj.generateSingletons(data, partition='validate', batch=10,**opts)
test_i, test_o, test_w = next(classifier_test_gen)
#print test_i

inputs  = Input(shape=(len(obj.default_variables),), name='input')
dense   = Dense(32, activation='tanh',name='dense1',kernel_initializer='lecun_uniform') (inputs)