Models Training Report

This utility function is designed for getting to know which models are the best for the dataset at hand. Manually training models one by one is troublesome as well as cumbersome. A smart and quick way of achieving this is by using the get_models_training_report() from quick_ml.training_predictions.
To get started, import the training_predictions module from quick_ml

After passing in the arguments for get_models_training_report, you will obtain a pandas dataframe. However, before getting into the details of the output and what are the parameters to be passed to the function, let's take a quick view of the table output format.

Output Table Overview

Table Preview of the Pandas DataFrame that is return upon calling the function to obtain training_report.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Table Description :-
1) Model Name -> Name of the model trained on the dataset
2) Top 1 Accuracy -> The last accuracy score on training dataset
3) Top 3 Accuracy -> The average of the last 3 accuracy scores on training dataset
4) Val Top 1 Accuracy -> The last validation accuracy score on validation dataset
5) Val Top 3 Accuracy -> The average of the last 3 validation accuracy scores on validation dataset

 

Using Models Training Report

Once you have successfully imported get_models_training_report, pass the arguments as per your requirement. The function returns a pandas dataframe with a table similar to above. The arguemnts are -

Arguments Description ->
    models - list of models to obtain the training report on. eg. models = ['VGG16', 'EfficientNetB7', 'InceptionV3', 'ResNet50']
    tpu - The TPU instance
    n_class - number of classes in the Dataset
    traindata - The training dataset (In TFRecords Dataset)
    steps_per_epoch - number of steps to be taken per epoch. Ideally, it should be number of training images // BATCH_SIZE
    epochs - Number of epochs for which models are to be trained.
    val_data - The validation dataset (In TFRecords Dataset)
    classification_model - The classification model which you want to attach as the top to the pretrained model. The 'default' classification model has a Global Average Pooling2D followed by Dense layer with output nodes same as the number of classes for classification.
You can define your own classification_model (Sequential Model) and pass the model as an argument to the classification model.

class_model = tf.keras.Sequential([ tf.keras.layers(), tf.keras.layers() ]) get_models_training_report(models, tpu, n_class, traindata, steps_per_epoch, epochs, val_data, classification_model = class_model)

    freeze - Whether or not you want to freeze the pretrained model weights. Default, False.
input_shape - Defines the input_shape of the images of the dataset. Default, [512,512,3]
    activation - The activation function for the final Dense layer of your Classification model. Default, 'softmax'. For binary classification, change to 'sigmoid' with n_class = 1.
    weights - The pretrained Model weights to be taken for consideration. Default, 'imagenet'. Support for 'noisy-student' coming soon.
    optimizer - The optimizer for the model to converge while training. Default, 'adam'
    loss - loss function to consider while training your deep learning model. Two options supported. 'Sparse Categorical CrossEntropy' & 'Binary Cross Entropy'. Default, 'Sparse Categorical CrossEntropy'.
    metrics - The metric to be taken under consideration while training your deep learning model. Two options available. 'accuracy' & 'sparse_categorical_accuracy'. Use 'accuracy' as a metric while doing Binary Classification else 'sparse_categorical_accuracy'. Default, 'sparse_categorical_accuracy'.
    plot - Plot the training curves of all the models for quick visualization. Feature Coming soon.


Returns =>
A Pandas Dataframe with a table output as shown above. You can save the function output in a variable and save the dataframe to your disk using .to_csv() method.

from quick_ml.training_predictions import get_models_training_report

get_models_training_report(models, tpu, n_class, traindata, steps_per_epoch, epochs, batch_size, val_data, classification_model = 'default', freeze = False, input_shape = [512,512,3], activation = 'softmax', weights = 'imagenet', optimizer = 'adam', loss = 'sparse_categorical_crossentropy', metrics = "sparse_categorical_accuracy", callbacks = None, plot = False)

Was this helpful?