Package: pansharpening
Lightning-Hydra-TemplateA clean template to kickstart your deep learning project 🚀⚡🔥Click onUse this templateto initialize new repository.Suggestions are always welcome!📌  IntroductionWhy you might want to use it:✅ Save on boilerplateEasily add new models, datasets, tasks, experiments, and train on different accelerators, like multi-GPU, TPU or SLURM clusters.✅ EducationThoroughly commented. You can use this repo as a learning resource.✅ ReusabilityCollection of useful MLOps tools, configs, and code snippets. You can use this repo as a reference for various utilities.Why you might not want to use it:❌ Things break from time to timeLightning and Hydra are still evolving and integrate many libraries, which means sometimes things break. For the list of currently known problems visitthis page.❌ Not adjusted for data engineeringTemplate is not really adjusted for building data pipelines that depend on each other. It's more efficient to use it for model prototyping on ready-to-use data.❌ Overfitted to simple use caseThe configuration setup is built with simple lightning training in mind. You might need to put some effort to adjust it for different use cases, e.g. lightning fabric.❌ Might not support your workflowFor example, you can't resume hydra-based multirun or hyperparameter search.Note:Keep in mind this is unofficial community project.Main TechnologiesPyTorch Lightning- a lightweight PyTorch wrapper for high-performance AI research. Think of it as a framework for organizing your PyTorch code.Hydra- a framework for elegantly configuring complex applications. The key feature is the ability to dynamically create a hierarchical configuration by composition and override it through config files and the command line.Main IdeasRapid Experimentation: thanks to hydra command line superpowersMinimal Boilerplate: thanks to automating pipelines with config instantiationMain Configs: allow you to specify default training configurationExperiment Configs: allow you to override chosen hyperparameters and version control experimentsWorkflow: comes down to 4 simple stepsExperiment Tracking: Tensorboard, W&B, Neptune, Comet, MLFlow and CSVLoggerLogs: all logs (checkpoints, configs, etc.) are stored in a dynamically generated folder structureHyperparameter Search: simple search is effortless with Hydra plugins like Optuna SweeperTests: generic, easy-to-adapt smoke tests for speeding up the developmentContinuous Integration: automatically test and lint your repo with Github ActionsBest Practices: a couple of recommended tools, practices and standardsProject StructureThe directory structure of new project looks like this:├── .github                   <- Github Actions workflows
│
├── configs                   <- Hydra configs
│   ├── callbacks                <- Callbacks configs
│   ├── data                     <- Data configs
│   ├── debug                    <- Debugging configs
│   ├── experiment               <- Experiment configs
│   ├── extras                   <- Extra utilities configs
│   ├── hparams_search           <- Hyperparameter search configs
│   ├── hydra                    <- Hydra configs
│   ├── local                    <- Local configs
│   ├── logger                   <- Logger configs
│   ├── model                    <- Model configs
│   ├── paths                    <- Project paths configs
│   ├── trainer                  <- Trainer configs
│   │
│   ├── eval.yaml             <- Main config for evaluation
│   └── train.yaml            <- Main config for training
│
├── data                   <- Project data
│
├── logs                   <- Logs generated by hydra and lightning loggers
│
├── notebooks              <- Jupyter notebooks. Naming convention is a number (for ordering),
│                             the creator's initials, and a short `-` delimited description,
│                             e.g. `1.0-jqp-initial-data-exploration.ipynb`.
│
├── scripts                <- Shell scripts
│
├── src                    <- Source code
│   ├── data                     <- Data scripts
│   ├── models                   <- Model scripts
│   ├── utils                    <- Utility scripts
│   │
│   ├── eval.py                  <- Run evaluation
│   └── train.py                 <- Run training
│
├── tests                  <- Tests of any kind
│
├── .env.example              <- Example of file for storing private environment variables
├── .gitignore                <- List of files ignored by git
├── .pre-commit-config.yaml   <- Configuration of pre-commit hooks for code formatting
├── .project-root             <- File for inferring the position of project root directory
├── environment.yaml          <- File for installing conda environment
├── Makefile                  <- Makefile with commands like `make train` or `make test`
├── pyproject.toml            <- Configuration options for testing and linting
├── requirements.txt          <- File for installing python dependencies
├── setup.py                  <- File for installing project as a package
└── README.md🚀  Quickstart# clone projectgitclonehttps://github.com/ashleve/lightning-hydra-templatecdlightning-hydra-template# [OPTIONAL] create conda environmentcondacreate-nmyenvpython=3.9
condaactivatemyenv# install pytorch according to instructions# https://pytorch.org/get-started/# install requirementspipinstall-rrequirements.txtTemplate contains example with MNIST classification.When runningpython src/train.pyyou should see something like this:⚡  Your SuperpowersOverride any config parameter from command linepythontrain.pytrainer.max_epochs=20model.optimizer.lr=1e-4Note: You can also add new parameters with+sign.pythontrain.py+model.new_param="owo"Train on CPU, GPU, multi-GPU and TPU# train on CPUpythontrain.pytrainer=cpu# train on 1 GPUpythontrain.pytrainer=gpu# train on TPUpythontrain.py+trainer.tpu_cores=8# train with DDP (Distributed Data Parallel) (4 GPUs)pythontrain.pytrainer=ddptrainer.devices=4# train with DDP (Distributed Data Parallel) (8 GPUs, 2 nodes)pythontrain.pytrainer=ddptrainer.devices=4trainer.num_nodes=2# simulate DDP on CPU processespythontrain.pytrainer=ddp_simtrainer.devices=2# accelerate training on macpythontrain.pytrainer=mpsWarning: Currently there are problems with DDP mode, readthis issueto learn more.Train with mixed precision# train with pytorch native automatic mixed precision (AMP)pythontrain.pytrainer=gpu+trainer.precision=16Train model with any logger available in PyTorch Lightning, like W&B or Tensorboard# set project and entity names in `configs/logger/wandb`wandb:project:"your_project_name"entity:"your_wandb_team_name"# train model with Weights&Biases (link to wandb dashboard should appear in the terminal)pythontrain.pylogger=wandbNote: Lightning provides convenient integrations with most popular logging frameworks. Learn morehere.Note: Using wandb requires you tosetup accountfirst. After that just complete the config as below.Note: Clickhereto see example wandb dashboard generated with this template.Train model with chosen experiment configpythontrain.pyexperiment=exampleNote: Experiment configs are placed inconfigs/experiment/.Attach some callbacks to runpythontrain.pycallbacks=defaultNote: Callbacks can be used for things such as as model checkpointing, early stopping andmany more.Note: Callbacks configs are placed inconfigs/callbacks/.Use different tricks available in Pytorch Lightning# gradient clipping may be enabled to avoid exploding gradientspython train.py +trainer.gradient_clip_val=0.5# run validation loop 4 times during a training epochpython train.py +trainer.val_check_interval=0.25# accumulate gradientspython train.py +trainer.accumulate_grad_batches=10# terminate training after 12 hourspython train.py +trainer.max_time="00:12:00:00"Note: PyTorch Lightning provides about40+ useful trainer flags.Easily debug# runs 1 epoch in default debugging mode# changes logging directory to `logs/debugs/...`# sets level of all command line loggers to 'DEBUG'# enforces debug-friendly configurationpythontrain.pydebug=default# run 1 train, val and test loop, using only 1 batchpythontrain.pydebug=fdr# print execution time profilingpythontrain.pydebug=profiler# try overfitting to 1 batchpythontrain.pydebug=overfit# raise exception if there are any numerical anomalies in tensors, like NaN or +/-infpythontrain.py+trainer.detect_anomaly=true# use only 20% of the datapythontrain.py+trainer.limit_train_batches=0.2\+trainer.limit_val_batches=0.2+trainer.limit_test_batches=0.2Note: Visitconfigs/debug/for different debugging configs.Resume training from checkpointpython train.py ckpt_path="/path/to/ckpt/name.ckpt"Note: Checkpoint can be either path or URL.Note: Currently loading ckpt doesn't resume logger experiment, but it will be supported in future Lightning release.Evaluate checkpoint on test datasetpython eval.py ckpt_path="/path/to/ckpt/name.ckpt"Note: Checkpoint can be either path or URL.Create a sweep over hyperparameters# this will run 6 experiments one after the other,# each with different combination of batch_size and learning ratepythontrain.py-mdata.batch_size=32,64,128model.lr=0.001,0.0005Note: Hydra composes configs lazily at job launch time. If you change code or configs after launching a job/sweep, the final composed configs might be impacted.Create a sweep over hyperparameters with Optuna# this will run hyperparameter search defined in `configs/hparams_search/mnist_optuna.yaml`# over chosen experiment configpythontrain.py-mhparams_search=mnist_optunaexperiment=exampleNote: UsingOptuna Sweeperdoesn't require you to add any boilerplate to your code, everything is defined in asingle config file.Warning: Optuna sweeps are not failure-resistant (if one job crashes then the whole sweep crashes).Execute all experiments from folderpythontrain.py-m'experiment=glob(*)'Note: Hydra provides special syntax for controlling behavior of multiruns. Learn morehere. The command above executes all experiments fromconfigs/experiment/.Execute run for multiple different seedspythontrain.py-mseed=1,2,3,4,5trainer.deterministic=Truelogger=csvtags=["benchmark"]Note:trainer.deterministic=Truemakes pytorch more deterministic but impacts the performance.Execute sweep on a remote AWS clusterNote: This should be achievable with simple config usingRay AWS launcher for Hydra. Example is not implemented in this template.Use Hydra tab completionNote: Hydra allows you to autocomplete config argument overrides in shell as you write them, by pressingtabkey. Read thedocs.Apply pre-commit hookspre-commitrun-aNote: Apply pre-commit hooks to do things like auto-formatting code and configs, performing code analysis or removing output from jupyter notebooks. See# Best Practicesfor more.Update pre-commit hook versions in.pre-commit-config.yamlwith:pre-commitautoupdateRun tests# run all testspytest# run tests from specific filepytesttests/test_train.py# run all tests except the ones marked as slowpytest-k"not slow"Use tagsEach experiment should be tagged in order to easily filter them across files or in logger UI:pythontrain.pytags=["mnist","experiment_X"]Note: You might need to escape the bracket characters in your shell withpython train.py tags=\["mnist","experiment_X"\].If no tags are provided, you will be asked to input them from command line:>>>pythontrain.pytags=[][2022-07-1115:40:09,358][src.utils.utils][INFO]-Enforcingtags!<cfg.extras.enforce_tags=True>[2022-07-1115:40:09,359][src.utils.rich_utils][WARNING]-Notagsprovidedinconfig.Promptingusertoinputtags...
Enteralistofcommaseparatedtags(dev):If no tags are provided for multirun, an error will be raised:>>>pythontrain.py-m+x=1,2,3tags=[]ValueError:Specifytagsbeforelaunchingamultirun!Note: Appending lists from command line is currently not supported in hydra :(❤️  ContributionsThis project exists thanks to all the people who contribute.Have a question? Found a bug? Missing a specific feature? Feel free to file a new issue, discussion or PR with respective title and description.Before making an issue, please verify that:The problem still exists on the currentmainbranch.Your python dependencies are updated to recent versions.Suggestions for improvements are always welcome!How It WorksAll PyTorch Lightning modules are dynamically instantiated from module paths specified in config. Example model config:_target_:src.models.mnist_model.MNISTLitModulelr:0.001net:_target_:src.models.components.simple_dense_net.SimpleDenseNetinput_size:784lin1_size:256lin2_size:256lin3_size:256output_size:10Using this config we can instantiate the object with the following line:model=hydra.utils.instantiate(config.model)This allows you to easily iterate over new models! Every time you create a new one, just specify its module path and parameters in appropriate config file.Switch between models and datamodules with command line arguments:pythontrain.pymodel=mnistExample pipeline managing the instantiation logic:src/train.py.Main ConfigLocation:configs/train.yamlMain project config contains default training configuration.It determines how config is composed when simply executing commandpython train.py.Show main project config# order of defaults determines the order in which configs override each otherdefaults:-_self_-data:mnist.yaml-model:mnist.yaml-callbacks:default.yaml-logger:null# set logger here or use command line (e.g. `python train.py logger=csv`)-trainer:default.yaml-paths:default.yaml-extras:default.yaml-hydra:default.yaml# experiment configs allow for version control of specific hyperparameters# e.g. best hyperparameters for given model and datamodule-experiment:null# config for hyperparameter optimization-hparams_search:null# optional local config for machine/user specific settings# it's optional since it doesn't need to exist and is excluded from version control-optional local:default.yaml# debugging config (enable through command line, e.g. `python train.py debug=default)-debug:null# task name, determines output directory pathtask_name:"train"# tags to help you identify your experiments# you can overwrite this in experiment configs# overwrite from command line with `python train.py tags="[first_tag, second_tag]"`# appending lists from command line is currently not supported :(# https://github.com/facebookresearch/hydra/issues/1547tags:["dev"]# set False to skip model trainingtrain:True# evaluate on test set, using best model weights achieved during training# lightning chooses best weights based on the metric specified in checkpoint callbacktest:True# simply provide checkpoint path to resume trainingckpt_path:null# seed for random number generators in pytorch, numpy and python.randomseed:nullExperiment ConfigLocation:configs/experimentExperiment configs allow you to overwrite parameters from main config.For example, you can use them to version control best hyperparameters for each combination of model and dataset.Show example experiment config# @package _global_# to execute this experiment run:# python train.py experiment=exampledefaults:-override /data:mnist.yaml-override /model:mnist.yaml-override /callbacks:default.yaml-override /trainer:default.yaml# all parameters below will be merged with parameters from default configurations set above# this allows you to overwrite only specified parameterstags:["mnist","simple_dense_net"]seed:12345trainer:min_epochs:10max_epochs:10gradient_clip_val:0.5model:optimizer:lr:0.002net:lin1_size:128lin2_size:256lin3_size:64data:batch_size:64logger:wandb:tags:${tags}group:"mnist"WorkflowBasic workflowWrite your PyTorch Lightning module (seemodels/mnist_module.pyfor example)Write your PyTorch Lightning datamodule (seedata/mnist_datamodule.pyfor example)Write your experiment config, containing paths to model and datamoduleRun training with chosen experiment config:pythonsrc/train.pyexperiment=experiment_name.yamlExperiment designSay you want to execute many runs to plot how accuracy changes in respect to batch size.Execute the runs with some config parameter that allows you to identify them easily, like tags:pythontrain.py-mlogger=csvdata.batch_size=16,32,64,128tags=["batch_size_exp"]Write a script or notebook that searches over thelogs/folder and retrieves csv logs from runs containing given tags in config. Plot the results.LogsHydra creates new output directory for every executed run.Default logging structure:├── logs
│   ├── task_name
│   │   ├── runs                        # Logs generated by single runs
│   │   │   ├── YYYY-MM-DD_HH-MM-SS       # Datetime of the run
│   │   │   │   ├── .hydra                  # Hydra logs
│   │   │   │   ├── csv                     # Csv logs
│   │   │   │   ├── wandb                   # Weights&Biases logs
│   │   │   │   ├── checkpoints             # Training checkpoints
│   │   │   │   └── ...                     # Any other thing saved during training
│   │   │   └── ...
│   │   │
│   │   └── multiruns                   # Logs generated by multiruns
│   │       ├── YYYY-MM-DD_HH-MM-SS       # Datetime of the multirun
│   │       │   ├──1                        # Multirun job number
│   │       │   ├──2
│   │       │   └── ...
│   │       └── ...
│   │
│   └── debugs                          # Logs generated when debugging config is attached
│       └── ...You can change this structure by modifying paths inhydra configuration.Experiment TrackingPyTorch Lightning supports many popular logging frameworks:Weights&Biases,Neptune,Comet,MLFlow,Tensorboard.These tools help you keep track of hyperparameters and output metrics and allow you to compare and visualize results. To use one of them simply complete its configuration inconfigs/loggerand run:pythontrain.pylogger=logger_nameYou can use many of them at once (seeconfigs/logger/many_loggers.yamlfor example).You can also write your own logger.Lightning provides convenient method for logging custom metrics from inside LightningModule. Read thedocsor take a look atMNIST example.TestsTemplate comes with generic tests implemented withpytest.# run all testspytest# run tests from specific filepytesttests/test_train.py# run all tests except the ones marked as slowpytest-k"not slow"Most of the implemented tests don't check for any specific output - they exist to simply verify that executing some commands doesn't end up in throwing exceptions. You can execute them once in a while to speed up the development.Currently, the tests cover cases like:running 1 train, val and test steprunning 1 epoch on 1% of data, saving ckpt and resuming for the second epochrunning 2 epochs on 1% of data, with DDP simulated on CPUAnd many others. You should be able to modify them easily for your use case.There is also@RunIfdecorator implemented, that allows you to run tests only if certain conditions are met, e.g. GPU is available or system is not windows. See theexamples.Hyperparameter SearchYou can define hyperparameter search by adding new config file toconfigs/hparams_search.Show example hyperparameter search config# @package _global_defaults:-override /hydra/sweeper:optuna# choose metric which will be optimized by Optuna# make sure this is the correct name of some metric logged in lightning module!optimized_metric:"val/acc_best"# here we define Optuna hyperparameter search# it optimizes for value returned from function with @hydra.main decoratorhydra:sweeper:_target_:hydra_plugins.hydra_optuna_sweeper.optuna_sweeper.OptunaSweeper# 'minimize' or 'maximize' the objectivedirection:maximize# total number of runs that will be executedn_trials:20# choose Optuna hyperparameter sampler# docs: https://optuna.readthedocs.io/en/stable/reference/samplers.htmlsampler:_target_:optuna.samplers.TPESamplerseed:1234n_startup_trials:10# number of random sampling runs before optimization starts# define hyperparameter search spaceparams:model.optimizer.lr:interval(0.0001, 0.1)data.batch_size:choice(32, 64, 128, 256)model.net.lin1_size:choice(64, 128, 256)model.net.lin2_size:choice(64, 128, 256)model.net.lin3_size:choice(32, 64, 128, 256)Next, execute it with:python train.py -m hparams_search=mnist_optunaUsing this approach doesn't require adding any boilerplate to code, everything is defined in a single config file. The only necessary thing is to return the optimized metric value from the launch file.You can use different optimization frameworks integrated with Hydra, likeOptuna, Ax or Nevergrad.Theoptimization_results.yamlwill be available underlogs/task_name/multirunfolder.This approach doesn't support resuming interrupted search and advanced techniques like prunning - for more sophisticated search and workflows, you should probably write a dedicated optimization task (without multirun feature).Continuous IntegrationTemplate comes with CI workflows implemented in Github Actions:.github/workflows/test.yaml: running all tests with pytest.github/workflows/code-quality-main.yaml: running pre-commits on main branch for all files.github/workflows/code-quality-pr.yaml: running pre-commits on pull requests for modified files onlyDistributed TrainingLightning supports multiple ways of doing distributed training. The most common one is DDP, which spawns separate process for each GPU and averages gradients between them. To learn about other approaches read thelightning docs.You can run DDP on mnist example with 4 GPUs like this:pythontrain.pytrainer=ddpNote: When using DDP you have to be careful how you write your models - read thedocs.Accessing Datamodule Attributes In ModelThe simplest way is to pass datamodule attribute directly to model on initialization:# ./src/train.pydatamodule=hydra.utils.instantiate(config.data)model=hydra.utils.instantiate(config.model,some_param=datamodule.some_param)Note: Not a very robust solution, since it assumes all your datamodules havesome_paramattribute available.Similarly, you can pass a whole datamodule config as an init parameter:# ./src/train.pymodel=hydra.utils.instantiate(config.model,dm_conf=config.data,_recursive_=False)You can also pass a datamodule config parameter to your model through variable interpolation:# ./configs/model/my_model.yaml_target_:src.models.my_module.MyLitModulelr:0.01some_param:${data.some_param}Another approach is to access datamodule in LightningModule directly through Trainer:# ./src/models/mnist_module.pydefon_train_start(self):self.some_param=self.trainer.datamodule.some_paramNote: This only works after the training starts since otherwise trainer won't be yet available in LightningModule.Best PracticesUse MinicondaIt's usually unnecessary to install full anaconda environment, miniconda should be enough (weights around 80MB).Big advantage of conda is that it allows for installing packages without requiring certain compilers or libraries to be available in the system (since it installs precompiled binaries), so it often makes it easier to install some dependencies e.g. cudatoolkit for GPU support.It also allows you to access your environments globally which might be more convenient than creating new local environment for every project.Example installation:wgethttps://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bashMiniconda3-latest-Linux-x86_64.shUpdate conda:condaupdate-nbase-cdefaultscondaCreate new conda environment:condacreate-nmyenvpython=3.10
condaactivatemyenvUse automatic code formattingUse pre-commit hooks to standardize code formatting of your project and save mental energy.Simply install pre-commit package with:pipinstallpre-commitNext, install hooks from.pre-commit-config.yaml:pre-commitinstallAfter that your code will be automatically reformatted on every new commit.To reformat all files in the project use command:pre-commitrun-aTo update hook versions in.pre-commit-config.yamluse:pre-commitautoupdateSet private environment variables in .env fileSystem specific variables (e.g. absolute paths to datasets) should not be under version control or it will result in conflict between different users. Your private keys also shouldn't be versioned since you don't want them to be leaked.Template contains.env.examplefile, which serves as an example. Create a new file called.env(this name is excluded from version control in .gitignore).
You should use it for storing environment variables like this:MY_VAR=/home/user/my_system_pathAll variables from.envare loaded intrain.pyautomatically.Hydra allows you to reference any env variable in.yamlconfigs like this:path_to_data:${oc.env:MY_VAR}Name metrics using '/' characterDepending on which logger you're using, it's often useful to define metric name with/character:self.log("train/loss",loss)This way loggers will treat your metrics as belonging to different sections, which helps to get them organised in UI.Use torchmetricsUse officialtorchmetricslibrary to ensure proper calculation of metrics. This is especially important for multi-GPU training!For example, instead of calculating accuracy by yourself, you should use the providedAccuracyclass like this:fromtorchmetrics.classification.accuracyimportAccuracyclassLitModel(LightningModule):def__init__(self)self.train_acc=Accuracy()self.val_acc=Accuracy()deftraining_step(self,batch,batch_idx):...acc=self.train_acc(predictions,targets)self.log("train/acc",acc)...defvalidation_step(self,batch,batch_idx):...acc=self.val_acc(predictions,targets)self.log("val/acc",acc)...Make sure to use different metric instance for each step to ensure proper value reduction over all GPU processes.Torchmetrics provides metrics for most use cases, like F1 score or confusion matrix. Readdocumentationfor more.Follow PyTorch Lightning style guideThe style guide is availablehere.Be explicit in your init. Try to define all the relevant defaults so that the user doesn’t have to guess. Provide type hints. This way your module is reusable across projects!classLitModel(LightningModule):def__init__(self,layer_size:int=256,lr:float=0.001):Preserve the recommended method order.classLitModel(LightningModule):def__init__():...defforward():...deftraining_step():...deftraining_step_end():...defon_train_epoch_end():...defvalidation_step():...defvalidation_step_end():...defon_validation_epoch_end():...deftest_step():...deftest_step_end():...defon_test_epoch_end():...defconfigure_optimizers():...defany_extra_hook():...Version control your data and models with DVCUseDVCto version control big files, like your data or trained ML models.To initialize the dvc repository:dvcinitTo start tracking a file or directory, usedvc add:dvcadddata/MNISTDVC stores information about the added file (or a directory) in a special .dvc file named data/MNIST.dvc, a small text file with a human-readable format. This file can be easily versioned like source code with Git, as a placeholder for the original data:gitadddata/MNIST.dvcdata/.gitignore
gitcommit-m"Add raw data"Support installing project as a packageIt allows other people to easily use your modules in their own projects.
Change name of thesrcfolder to your project name and complete thesetup.pyfile.Now your project can be installed from local files:pipinstall-e.Or directly from git repository:pipinstallgit+git://github.com/YourGithubName/your-repo-name.git--upgradeSo any file can be easily imported into any other file like so:fromproject_name.models.mnist_moduleimportMNISTLitModulefromproject_name.data.mnist_datamoduleimportMNISTDataModuleKeep local configs out of code versioningSome configurations are user/machine/installation specific (e.g. configuration of local cluster, or harddrive paths on a specific machine). For such scenarios, a fileconfigs/local/default.yamlcan be created which is automatically loaded but not tracked by Git.For example, you can use it for a SLURM cluster config:# @package _global_defaults:-override /hydra/launcher@_here_:submitit_slurmdata_dir:/mnt/scratch/data/hydra:launcher:timeout_min:1440gpus_per_task:1gres:gpu:1job:env_set:MY_VAR:/home/user/my/system/pathMY_KEY:asdgjhawi8y23ihsghsueity23ihwdResourcesThis template was inspired by:PyTorchLightning/deep-learning-project-templatedrivendata/cookiecutter-data-sciencelucmos/nn-templateOther useful repositories:jxpress/lightning-hydra-template-vertex-ai- lightning-hydra-template integration with Vertex AI hyperparameter tuning and custom training jobLicenseLightning-Hydra-Template is licensed under the MIT License.MIT License

Copyright (c) 2021 ashleve

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.DELETE EVERYTHING ABOVE FOR YOUR PROJECTYour Project NameDescriptionWhat it doesInstallationPip# clone projectgitclonehttps://github.com/YourGithubName/your-repo-namecdyour-repo-name# [OPTIONAL] create conda environmentcondacreate-nmyenvpython=3.9
condaactivatemyenv# install pytorch according to instructions# https://pytorch.org/get-started/# install requirementspipinstall-rrequirements.txtConda# clone projectgitclonehttps://github.com/YourGithubName/your-repo-namecdyour-repo-name# create conda environment and install dependenciescondaenvcreate-fenvironment.yaml-nmyenv# activate conda environmentcondaactivatemyenvHow to runTrain model with default configuration# train on CPUpythonsrc/train.pytrainer=cpu# train on GPUpythonsrc/train.pytrainer=gpuTrain model with chosen experiment configuration fromconfigs/experiment/pythonsrc/train.pyexperiment=experiment_name.yamlYou can override any parameter from command line like thispythonsrc/train.pytrainer.max_epochs=20data.batch_size=64