Tensorflow and Roostats

Dear experts,

I have a simple model built using TensorFlow to determine if an input tensor is signal or background.

model1 = Sequential()

model1.add(Conv2D(4,  kernel_size=3, activation='elu', input_shape=(X_train.shape[1], X_train.shape[2], 1)))
model1.add(MaxPooling2D(pool_size=(2, 2)))
model1.add(Conv2D(8,  kernel_size=3, activation='sigmoid'))
model1.add(MaxPooling2D(pool_size=(2, 2)))
model1.add(Conv2D(16, kernel_size=3, activation='sigmoid'))
model1.add(Flatten())
model1.add(Dense(200, activation='sigmoid'))
model1.add(Dense(100, activation='sigmoid'))
model1.add(Dense(Y_train.shape[1], activation='sigmoid'))

model1.compile(optimizer='adam', loss='binary_crossentropy')

checkpoint = keras.callbacks.ModelCheckpoint(nameModelFile, verbose=1, monitor='val_loss', save_best_only=True, mode='auto') 

train_history = model1.fit(X_train, Y_train, batch_size=200, epochs=50, validation_split=0.2, callbacks=[checkpoint])

model1.load_weights(nameModelFile)

It is not clear to me how I should proceed once the model has been trained. How do I go from my trained model to something that RooStats can use to perform a hypothesis test and calculate the discovery significance or set a limit?

If you could provide some insights into how I should proceed or have some examples or reading material available that I could look into, it will be greatly appreciated.

Regards,
Deshan

Hi @dabhayas,

you need a function that can be evaluated from C++. The RooStats tools use the interface of RooAbsPdf to evaluate, normalise and alter parameters.
You should override createNLL() to return a RooAbsReal, which returns the negative log-likelihood computed from the tensorflow model when getVal() is called.

1 Like

Hi Stephan,

Thanks for the clarification. I’ll try this out.

Regards,
Deshan

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.