Machine learning problems often require dealing with large quantities of training data with limited computing resources, particularly memory. It is not always possible to load an entire training set into memory. Fortunately, this can be dealt with through the use of Keras' fit_generator method, Python generators, and HDF5 file format.
You can create a custom loss function and metrics in Keras by defining a TensorFlow/Theano symbolic function that returns a scalar for each data-point and takes the following two arguments: tensor of true values, tensor of the corresponding predicted values.
Note that the loss/metric (for display and optimization) is calculated as the mean of the losses/metric across all datapoints in the batch.
This topic includes short, brief but comprehensive examples of loading pre-trained weights, inserting new layers on top or in the middle of pre-tained ones, and training a new network with partly pre-trained weights. An example for each of out-of-the-box pre-trained networks, available in Keras library (VGG, ResNet, Inception, Xception, MobileNet), is required.