mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-18 12:50:58 +08:00
286 lines
11 KiB
HTML
286 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
|
<link rel="shortcut icon" href="../img/favicon.ico">
|
|
<title>Trainer - Pytorch lightning Documentation</title>
|
|
<link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
|
|
|
|
<link rel="stylesheet" href="../css/theme.css" type="text/css" />
|
|
<link rel="stylesheet" href="../css/theme_extra.css" type="text/css" />
|
|
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css">
|
|
|
|
<script>
|
|
// Current page data
|
|
var mkdocs_page_name = "Trainer";
|
|
var mkdocs_page_input_path = "Trainer/index.md";
|
|
var mkdocs_page_url = null;
|
|
</script>
|
|
|
|
<script src="../js/jquery-2.1.1.min.js" defer></script>
|
|
<script src="../js/modernizr-2.8.3.min.js" defer></script>
|
|
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav" role="document">
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
|
|
<div class="wy-side-nav-search">
|
|
<a href=".." class="icon icon-home"> Pytorch lightning Documentation</a>
|
|
<div role="search">
|
|
<form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
<ul class="current">
|
|
|
|
|
|
<li class="toctree-l1">
|
|
|
|
<a class="" href="..">PYTORCH-LIGHTNING DOCUMENTATION</a>
|
|
</li>
|
|
|
|
<li class="toctree-l1">
|
|
|
|
<a class="" href="../Examples/">Examples</a>
|
|
</li>
|
|
|
|
<li class="toctree-l1">
|
|
|
|
<span class="caption-text">LightningModule</span>
|
|
<ul class="subnav">
|
|
<li class="">
|
|
|
|
<a class="" href="../LightningModule/RequiredTrainerInterface/">Lightning Module interface</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="../LightningModule/methods/">Methods</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="../LightningModule/properties/">Properties</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
|
|
<li class="toctree-l1">
|
|
|
|
<span class="caption-text">Trainer</span>
|
|
<ul class="subnav">
|
|
<li class=" current">
|
|
|
|
<a class="current" href="./">Trainer</a>
|
|
<ul class="subnav">
|
|
|
|
<li class="toctree-l3"><a href="#trainer">Trainer</a></li>
|
|
|
|
|
|
</ul>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="Checkpointing/">Checkpointing</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="Distributed training/">Distributed training</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="Logging/">Logging</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="SLURM Managed Cluster/">SLURM Managed Cluster</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="Training Loop/">Training Loop</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="Validation loop/">Validation loop</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="debugging/">Debugging</a>
|
|
</li>
|
|
<li class="">
|
|
|
|
<a class="" href="hooks/">Hooks</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="..">Pytorch lightning Documentation</a>
|
|
</nav>
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content">
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
<ul class="wy-breadcrumbs">
|
|
<li><a href="..">Docs</a> »</li>
|
|
|
|
|
|
|
|
<li>Trainer »</li>
|
|
|
|
|
|
|
|
<li>Trainer</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
<a href="https://github.com/williamFalcon/pytorch-lightning/edit/master/docs/Trainer/index.md"
|
|
class="icon icon-github"> Edit on GitHub</a>
|
|
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
</div>
|
|
<div role="main">
|
|
<div class="section">
|
|
|
|
<h1 id="trainer">Trainer</h1>
|
|
<p>[<a href="https://github.com/williamFalcon/pytorch-lightning/blob/master/pytorch_lightning/models/trainer.py">Github Code</a>]</p>
|
|
<p>The lightning trainer abstracts best practices for running a training, val, test routine. It calls parts of your model when it wants to hand over full control and otherwise makes training assumptions which are now standard practice in AI research.</p>
|
|
<p>This is the basic use of the trainer:</p>
|
|
<pre><code class="python">from pytorch_lightning import Trainer
|
|
|
|
model = LightningTemplate()
|
|
|
|
trainer = Trainer()
|
|
trainer.fit(model)
|
|
</code></pre>
|
|
|
|
<p>But of course the fun is in all the advanced things it can do:</p>
|
|
<p><strong>Checkpointing</strong> </p>
|
|
<ul>
|
|
<li>Model saving</li>
|
|
<li>Model loading </li>
|
|
</ul>
|
|
<p><strong>Computing cluster (SLURM)</strong> </p>
|
|
<ul>
|
|
<li><a href="SLURM%20Managed%20Cluster/#running-grid-search-on-a-cluster">Running grid search on a cluster</a></li>
|
|
<li><a href="SLURM%20Managed%20Cluster/#walltime-auto-resubmit">Walltime auto-resubmit</a> </li>
|
|
</ul>
|
|
<p><strong>Debugging</strong> </p>
|
|
<ul>
|
|
<li><a href="Debugging/#fast-dev-run">Fast dev run</a></li>
|
|
<li><a href="Debugging/#inspect-gradient-norms">Inspect gradient norms</a></li>
|
|
<li><a href="Debugging/#Log-gpu-usage">Log GPU usage</a></li>
|
|
<li><a href="Debugging/#make-model-overfit-on-subset-of-data">Make model overfit on subset of data</a></li>
|
|
<li><a href="Debugging/#print-the-parameter-count-by-layer">Print the parameter count by layer</a></li>
|
|
<li><a href="Debugging/#print-which-gradients-are-nan">Pring which gradients are nan</a></li>
|
|
</ul>
|
|
<p><strong>Distributed training</strong> </p>
|
|
<ul>
|
|
<li><a href="Distributed%20training/#16-bit-mixed-precision">16-bit mixed precision</a></li>
|
|
<li><a href="Distributed%20training/#Multi-GPU">Multi-GPU</a></li>
|
|
<li><a href="Distributed%20training/#Multi-node">Multi-node</a></li>
|
|
<li><a href="Distributed%20training/#single-gpu">Single GPU</a></li>
|
|
<li><a href="Distributed%20training/#self-balancing-architecture">Self-balancing architecture</a></li>
|
|
</ul>
|
|
<p><strong>Experiment Logging</strong> </p>
|
|
<ul>
|
|
<li><a href="Logging/#display-metrics-in-progress-bar">Display metrics in progress bar</a></li>
|
|
<li>Log arbitrary metrics</li>
|
|
<li><a href="Logging/#log-metric-row-every-k-batches">Log metric row every k batches</a></li>
|
|
<li><a href="Logging/#process-position">Process position</a></li>
|
|
<li><a href="Logging/#save-a-snapshot-of-all-hyperparameters">Save a snapshot of all hyperparameters</a> </li>
|
|
<li><a href="Logging/#snapshot-code-for-a-training-run">Snapshot code for a training run</a> </li>
|
|
<li><a href="Logging/#write-logs-file-to-csv-every-k-batches">Write logs file to csv every k batches</a></li>
|
|
</ul>
|
|
<p><strong>Training loop</strong> </p>
|
|
<ul>
|
|
<li><a href="Training%20Loop/#accumulated-gradients">Accumulate gradients</a></li>
|
|
<li><a href="Training%20Loop/#anneal-learning-rate">Anneal Learning rate</a></li>
|
|
<li><a href="Training%20Loop/#force-training-for-min-or-max-epochs">Force training for min or max epochs</a></li>
|
|
<li><a href="Training%20Loop/#force-disable-early-stop">Force disable early stop</a></li>
|
|
<li><a href="../Pytorch-lightning/LightningModule/#configure_optimizers">Use multiple optimizers (like GANs)</a></li>
|
|
<li><a href="Training%20Loop/#set-how-much-of-the-training-set-to-check">Set how much of the training set to check (1-100%)</a></li>
|
|
</ul>
|
|
<p><strong>Validation loop</strong> </p>
|
|
<ul>
|
|
<li><a href="Validation%20Loop/#check-validation-every-n-epochs">Check validation every n epochs</a></li>
|
|
<li><a href="Validation%20Loop/#set-how-much-of-the-validation-set-to-check">Set how much of the validation set to check</a></li>
|
|
<li><a href="Validation%20Loop/#set-how-much-of-the-test-set-to-check">Set how much of the test set to check</a></li>
|
|
<li><a href="Validation%20Loop/#set-validation-check-frequency-within-1-training-epoch">Set validation check frequency within 1 training epoch</a></li>
|
|
<li><a href="Validation%20Loop/#set-the-number-of-validation-sanity-steps">Set the number of validation sanity steps</a></li>
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="Checkpointing/" class="btn btn-neutral float-right" title="Checkpointing">Next <span class="icon icon-circle-arrow-right"></span></a>
|
|
|
|
|
|
<a href="../LightningModule/properties/" class="btn btn-neutral" title="Properties"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
|
|
|
</div>
|
|
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<!-- Copyright etc -->
|
|
|
|
</div>
|
|
|
|
Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
<div class="rst-versions" role="note" style="cursor: pointer">
|
|
<span class="rst-current-version" data-toggle="rst-current-version">
|
|
|
|
<a href="https://github.com/williamFalcon/pytorch-lightning/" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a>
|
|
|
|
|
|
<span><a href="../LightningModule/properties/" style="color: #fcfcfc;">« Previous</a></span>
|
|
|
|
|
|
<span style="margin-left: 15px"><a href="Checkpointing/" style="color: #fcfcfc">Next »</a></span>
|
|
|
|
</span>
|
|
</div>
|
|
<script>var base_url = '..';</script>
|
|
<script src="../js/theme.js" defer></script>
|
|
<script src="../search/main.js" defer></script>
|
|
|
|
</body>
|
|
</html>
|