Compilation of the module
Compilation configure the learning process of the module.
It is done via compile method.
It takes 3 arguments.
Optimizer
Can use string identifier of an existing optimizer (rmsprop | adagrad) or instance of an existing Optimizer.
Loss Function
Model always tries to minimize the loss.Can use existing string identifier of an loss function ( mse | categorical_crossentropy)or an objective function.
A list of metrics
For any classification problem set metrics to accuracy.
metrics=['accuracy']
metric could be a string identifier , existing metric or custom metric function.
# For a binary classification problem
model.compile(optimizer='rmsprop',
loss='binary_crossentropy',
metrics=['accuracy'])
# For a mean squared error regression problem
model.compile(optimizer='rmsprop',
loss='mse')
# For custom metrics
import keras.backend as K
def mean_pred(y_true, y_pred):
return K.mean(y_pred)
model.compile(optimizer='rmsprop',
loss='binary_crossentropy',
metrics=['accuracy', mean_pred])
Comments
Post a Comment