This commit is contained in:
Adam J. Stewart 2021-09-24 16:48:13 -05:00 коммит произвёл Caleb Robinson
Родитель 10508dcad4
Коммит 9911afef89
2 изменённых файлов: 14 добавлений и 14 удалений

Просмотреть файл

@ -26,8 +26,8 @@ torchgeo
:caption: Tutorials
tutorials/getting_started
tutorials/trainers
tutorials/benchmarking
tutorials/trainer
.. toctree::
:maxdepth: 1

Просмотреть файл

@ -17,9 +17,9 @@
"id": "NdrXRgjU7Zih"
},
"source": [
"# Training models\n",
"# PyTorch Lightning trainers\n",
"\n",
"In this tutorial, we demonstrate TorchGeo trainers to train and test a model. Specifically, we will use the [Tropical Cyclone dataset](https://torchgeo.readthedocs.io/en/latest/api/datasets.html#tropical-cyclone-wind-estimation-competition) and train models to predict cyclone windspeed given imagery of the cyclone. \n",
"In this tutorial, we demonstrate TorchGeo trainers to train and test a model. Specifically, we use the [Tropical Cyclone dataset](https://torchgeo.readthedocs.io/en/latest/api/datasets.html#tropical-cyclone-wind-estimation-competition) and train models to predict cyclone windspeed given imagery of the cyclone. \n",
"\n",
"It's recommended to run this notebook on Google Colab if you don't have your own GPU. Click the \"Open in Colab\" button above to get started."
]
@ -98,14 +98,14 @@
"id": "5rLknZxrBEMz"
},
"source": [
"## Setup lightning modules\n",
"## Lightning modules\n",
"\n",
"Our trainers use [PyTorch Lightning](https://pytorch-lightning.readthedocs.io/en/latest/) to organize both the training code, and the dataloader setup code. This makes it easy to create and share reproducible experiments and results.\n",
"Our trainers use [PyTorch Lightning](https://pytorch-lightning.readthedocs.io/) to organize both the training code, and the dataloader setup code. This makes it easy to create and share reproducible experiments and results.\n",
"\n",
"First we'll create a `CycloneDataModule` object which is simply a wrapper around the [`TropicalCycloneWindEstimation`](https://torchgeo.readthedocs.io/en/latest/api/datasets.html#tropical-cyclone-wind-estimation-competition) dataset. This object 1.) ensures that the data is downloaded*, 2.) sets up PyTorch `DataLoader` objects for the train, validation, and test splits, and 3.) ensures that data from the same cyclone **is not** shared between the training and validation sets so that you can properly evaluate the generalization performance of your model.\n",
"\n",
"\n",
"*To automatically download the dataset, you need an API key from the [Radiant Earth MLHub](https://mlhub.earth/). This is completely free, and will give you access to a growing catalog of ML ready remote sensing datasets."
"*To automatically download the dataset, you need an API key from the [Radiant Earth MLHub](https://mlhub.earth/). This is completely free, and will give you access to a growing catalog of ML-ready remote sensing datasets."
]
},
{
@ -115,7 +115,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Set this to your API key (available free at https://mlhub.earth/)\n",
"# Set this to your API key (available for free at https://mlhub.earth/)\n",
"RADIANT_EARTH_API_KEY = \"\""
]
},
@ -176,7 +176,7 @@
"source": [
"## Training\n",
"\n",
"Now that we have the Lightning modules setup, we can use a PyTorch Lightning [`Trainer`](https://pytorch-lightning.readthedocs.io/en/latest/common/trainer.html) to run the the training and evaluation loops. There are many useful pieces of configuration that can be set in the `Trainer` -- below we setup model checkpointing based on the validation loss, early stopping based on the validation loss, and a CSV based logger. We encourage you to see the [PyTorch Lightning docs](https://pytorch-lightning.readthedocs.io/en/latest/) for other options that can be set here, e.g.: Tensorboard logging, automatically selecting your optimizer's learning rate, and easy multi-GPU training."
"Now that we have the Lightning modules set up, we can use a PyTorch Lightning [`Trainer`](https://pytorch-lightning.readthedocs.io/en/latest/common/trainer.html) to run the the training and evaluation loops. There are many useful pieces of configuration that can be set in the `Trainer` -- below we set up model checkpointing based on the validation loss, early stopping based on the validation loss, and a CSV based logger. We encourage you to see the [PyTorch Lightning docs](https://pytorch-lightning.readthedocs.io/) for other options that can be set here, e.g. Tensorboard logging, automatically selecting your optimizer's learning rate, and easy multi-GPU training."
]
},
{
@ -249,7 +249,7 @@
"id": "c88b034f",
"metadata": {},
"source": [
"When we first call `.fit(...)` the dataset will be downloaded and checksummed (if it hasn't already). This can take 5-10 minutes. After this, the training process will kick off, and results will be saved to a CSV file. "
"When we first call `.fit(...)` the dataset will be downloaded and checksummed (if it hasn't already). This can take 510 minutes. After this, the training process will kick off, and results will be saved to a CSV file. "
]
},
{
@ -523,8 +523,8 @@
"plt.plot(train_steps, train_rmse, label=\"Train RMSE\")\n",
"plt.plot(val_steps, val_rmse, label=\"Validation RMSE\")\n",
"plt.legend(fontsize=15)\n",
"plt.xlabel(\"Batches\",fontsize=15)\n",
"plt.ylabel(\"RMSE\",fontsize=15)\n",
"plt.xlabel(\"Batches\", fontsize=15)\n",
"plt.ylabel(\"RMSE\", fontsize=15)\n",
"plt.show()\n",
"plt.close()"
]
@ -600,9 +600,9 @@
"timeout": 1200
},
"kernelspec": {
"display_name": "torchgeo",
"display_name": "Python 3",
"language": "python",
"name": "conda-env-torchgeo-py"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
@ -614,7 +614,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
"version": "3.8.11"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {