- Split the dataset Split the FETAL dataset into train/val/test sets.
python split_dataset.py
- Your first experiment We created a
base_modeldirectory for you under theexperimentsdirectory. It contains a fileparams.jsonwhich sets the hyperparameters for the experiment. It looks like
{
"learning_rate": 1e-3,
"batch_size": 32,
"num_epochs": 10,
...
}For every new experiment, you will need to create a new directory under experiments with a similar params.json file.
- Train your experiment. Simply run
python train.py --data_dir data/FETAL --model_dir experiments/base_model
It will instantiate a model and train it on the training set following the hyperparameters specified in params.json. It will also evaluate some metrics on the validation set.
- Your first hyperparameters search We created a new directory
learning_rateinexperimentsfor you. Now, run
python search_hyperparams.py --data_dir data/FETAL --parent_dir experiments/learning_rate
It will train and evaluate a model with different values of learning rate defined in search_hyperparams.py and create a new directory for each experiment under experiments/learning_rate/.
- Display the results of the hyperparameters search in a nice format
python synthesize_results.py --parent_dir experiments/learning_rate
- Evaluation on the test set Once you've run many experiments and selected your best model and hyperparameters based on the performance on the validation set, you can finally evaluate the performance of your model on the test set. Run
python evaluate.py --data_dir data/FETAL --model_dir experiments/base_model
We recommend reading through train.py to get a high-level overview of the training loop steps:
- loading the hyperparameters for the experiment (the
params.json) - loading the training and validation data
- creating the model, loss_fn and metrics
- training the model for a given number of epochs by calling
train_and_evaluate(...)
You can then have a look at data_loader.py to understand:
- how jpg images are loaded and transformed to torch Tensors
- how the
data_iteratorcreates a batch of data and labels and pads sentences
Once you get the high-level idea, depending on your dataset, you might want to modify
model/net.pyto change the neural network, loss function and metricsmodel/data_loader.pyto suit the data loader to your specific needstrain.pyfor changing the optimizertrain.pyandevaluate.pyfor some changes in the model or input require changes here