Adaptation Example of the Model Fine-Tuning Startup Script (argparse)
import argparse
import logging
# Simulate the logic of the model source code.
def model_finetune(args):
logging.info('%s', args.data_path) # Receive corresponding parameters from the model code.
logging.info('%s', args.output_path)
logging.info('%s', args.advanced_config)
logging.info('%s', args.learning_rate)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
# The following is mandatory adaptation parameters.
parser.add_argument('-dp', '--data_path', type=str, required=True) # Dataset path
parser.add_argument('-op', '--output_path', type=str, required=True) # Output path
# The following is optional adaptation parameters.
parser.add_argument('-pm', '--pretrained_model_path', type=str, required=False) # Pre-trained model path
parser.add_argument('-ac', '--advanced_config', type=str, required=False) # Model configuration file path. It is used only when the model network needs to be frozen.
# params configuration items contained in the model configuration file
parser.add_argument('-lr', '--learning_rate', type=float, required=False)
parser.add_argument('-bs', '--batch_size', type=int, required=False)
# Parameter sets received by the model script
args = parser.parse_args()
model_finetune(args)
The following is content of the params configuration items:
params: learning_rate: 1e-6 batch_size: 32
Parent topic: Model Adaptation Examples