Transfer Learning using ResNet Model
Learn how to train, evaluate, and visualize the performance of a ResNet model.
We train the ResNet model by applying the train_one_epoch function for the desired number of epochs. This is a few epochs since we are fine-tuning the network.
Set up TensorBoard in Flax
To monitor model training via TensorBoard, we can write the training and validation metrics to TensorBoard.
In the code above:
Line 1: We import the
SummaryWritermodule fromtorch.utils.tensorboardto log in to TensorBoard.Line 3: We define the
logdirvariable to store the path of the logging directory.Line 4: We create an instance of
SummaryWriterwithlogdirto store the TensorBoard logs.
Train model
We define a function to train and evaluate the model while writing the metrics to TensorBoard.
In the code above: ...