Exemplo n.º 1
0
NEPOCH = 50
APOSTLE = 'v4_nopt'
system('cp %s shallow_models/train_%s.py' % (argv[0], APOSTLE))
''' 
instantiate data loaders 
'''
top = make_coll(basedir + '/PARTITION/Top_*_CATEGORY.npy')
qcd = make_coll(basedir + '/PARTITION/QCD_*_CATEGORY.npy')

data = [top, qcd]
'''
first build the classifier!
'''

# set up data
classifier_train_gen = generate(data, partition='train', batch=1000)
classifier_validation_gen = generate(data, partition='validate', batch=10000)
classifier_test_gen = generate(data, partition='test', batch=10)
test_i, test_o, test_w = next(classifier_test_gen)
#print test_i

inputs = Input(shape=(len(config.gen_default_variables), ), name='input')
dense = Dense(32,
              activation='tanh',
              name='dense1',
              kernel_initializer='lecun_uniform')(inputs)
dense = Dense(32,
              activation='tanh',
              name='dense2',
              kernel_initializer='lecun_uniform')(dense)
dense = Dense(32,
Exemplo n.º 2
0
APOSTLE = 'v4_0'
modeldir = 'cce_adversary/'
system('mkdir -p %s'%modeldir)
system('cp %s %s/train_%s.py'%(argv[0], modeldir, APOSTLE))

### instantiate data loaders ### 
top = make_coll(basedir + '/PARTITION/Top_*_CATEGORY.npy')
qcd = make_coll(basedir + '/PARTITION/QCD_*_CATEGORY.npy')

data = [top, qcd]

### first build the classifier! ###

# set up data 
opts = {'decorr_mass':False}
classifier_train_gen = generate(data, partition='train', batch=1000, **opts)
classifier_validation_gen = generate(data, partition='validate', batch=10000, **opts)
classifier_test_gen = generate(data, partition='test', batch=10, **opts)
test_i, test_o, test_w = next(classifier_test_gen)

inputs  = Input(shape=(len(config.gen_default_variables),), name='input')

dense   = Dense(32, activation='tanh',name='dense1',kernel_initializer='lecun_uniform') (inputs)
dense   = Dense(32, activation='tanh',name='dense2',kernel_initializer='lecun_uniform') (dense)
dense   = Dense(32, activation='tanh',name='dense3',kernel_initializer='lecun_uniform') (dense)
y_hat   = Dense(config.n_truth, activation='softmax')                                   (dense)

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