.. role:: hidden :class: hidden-section Retrain a Pretrained Model Using A URI ************************************** .. code-block:: python import poutyne from deepparse import download_from_public_repository from deepparse.dataset_container import PickleDatasetContainer from deepparse.parser import AddressParser First, let's download the train and test data from the public repository. .. code-block:: python saving_dir = "./data" file_extension = "p" training_dataset_name = "sample_incomplete_data" test_dataset_name = "test_sample_data" download_from_public_repository(training_dataset_name, saving_dir, file_extension=file_extension) download_from_public_repository(test_dataset_name, saving_dir, file_extension=file_extension) Now let's create a training and test container. .. code-block:: python training_container = PickleDatasetContainer(os.path.join(saving_dir, training_dataset_name + "." + file_extension)) test_container = PickleDatasetContainer(os.path.join(saving_dir, test_dataset_name + "." + file_extension)) We will retrain the ``FastText`` version of our pretrained model. .. code-block:: python path_to_your_uri = "s3:///fasttext.ckpt" address_parser = AddressParser(model_type="fasttext", device=0, path_to_retrained_model=path_to_your_uri) Now, let's retrain for ``5`` epochs using a batch size of ``8`` since the data is really small for the example. Let's start with the default learning rate of ``0.01`` and use a learning rate scheduler to lower the learning rate as we progress. .. code-block:: python # Reduce LR by a factor of 10 each epoch lr_scheduler = poutyne.StepLR(step_size=1, gamma=0.1) The retrained model best checkpoint (ckpt) will be saved in the S3 Bucket