mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-09 11:32:07 +08:00
Deployed 48bc346 with MkDocs version: 1.0.4
This commit is contained in:
@@ -949,9 +949,9 @@ from torch.utils.data import DataLoader
|
||||
from torchvision.datasets import MNIST
|
||||
import torchvision.transforms as transforms
|
||||
|
||||
import pytorch_lightning as ptl
|
||||
import pytorch_lightning as pl
|
||||
|
||||
class CoolModel(ptl.LightningModule):
|
||||
class CoolModel(pl.LightningModule):
|
||||
|
||||
def __init__(self):
|
||||
super(CoolModel, self).__init__()
|
||||
@@ -981,15 +981,15 @@ class CoolModel(ptl.LightningModule):
|
||||
def configure_optimizers(self):
|
||||
return [torch.optim.Adam(self.parameters(), lr=0.02)]
|
||||
|
||||
@ptl.data_loader
|
||||
@pl.data_loader
|
||||
def tng_dataloader(self):
|
||||
return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=transforms.ToTensor()), batch_size=32)
|
||||
|
||||
@ptl.data_loader
|
||||
@pl.data_loader
|
||||
def val_dataloader(self):
|
||||
return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=transforms.ToTensor()), batch_size=32)
|
||||
|
||||
@ptl.data_loader
|
||||
@pl.data_loader
|
||||
def test_dataloader(self):
|
||||
return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=transforms.ToTensor()), batch_size=32)
|
||||
</code></pre>
|
||||
@@ -1248,15 +1248,15 @@ If you saved something with <strong>on_save_checkpoint</strong> this is your cha
|
||||
|
||||
<hr />
|
||||
<h3 id="tng_dataloader">tng_dataloader</h3>
|
||||
<pre><code class="python">@ptl.data_loader
|
||||
<pre><code class="python">@pl.data_loader
|
||||
def tng_dataloader(self)
|
||||
</code></pre>
|
||||
|
||||
<p>Called by lightning during training loop. Make sure to use the @ptl.data_loader decorator, this ensures not calling this function until the data are needed.</p>
|
||||
<p>Called by lightning during training loop. Make sure to use the @pl.data_loader decorator, this ensures not calling this function until the data are needed.</p>
|
||||
<h5 id="return_3">Return</h5>
|
||||
<p>PyTorch DataLoader</p>
|
||||
<p><strong>Example</strong></p>
|
||||
<pre><code class="python">@ptl.data_loader
|
||||
<pre><code class="python">@pl.data_loader
|
||||
def tng_dataloader(self):
|
||||
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (1.0,))])
|
||||
dataset = MNIST(root='/path/to/mnist/', train=True, transform=transform, download=True)
|
||||
@@ -1270,15 +1270,15 @@ def tng_dataloader(self):
|
||||
|
||||
<hr />
|
||||
<h3 id="val_dataloader">val_dataloader</h3>
|
||||
<pre><code class="python">@ptl.data_loader
|
||||
<pre><code class="python">@pl.data_loader
|
||||
def tng_dataloader(self)
|
||||
</code></pre>
|
||||
|
||||
<p>Called by lightning during validation loop. Make sure to use the @ptl.data_loader decorator, this ensures not calling this function until the data are needed.</p>
|
||||
<p>Called by lightning during validation loop. Make sure to use the @pl.data_loader decorator, this ensures not calling this function until the data are needed.</p>
|
||||
<h5 id="return_4">Return</h5>
|
||||
<p>PyTorch DataLoader</p>
|
||||
<p><strong>Example</strong></p>
|
||||
<pre><code class="python">@ptl.data_loader
|
||||
<pre><code class="python">@pl.data_loader
|
||||
def val_dataloader(self):
|
||||
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (1.0,))])
|
||||
dataset = MNIST(root='/path/to/mnist/', train=False, transform=transform, download=True)
|
||||
@@ -1293,15 +1293,15 @@ def val_dataloader(self):
|
||||
|
||||
<hr />
|
||||
<h3 id="test_dataloader">test_dataloader</h3>
|
||||
<pre><code class="python">@ptl.data_loader
|
||||
<pre><code class="python">@pl.data_loader
|
||||
def test_dataloader(self)
|
||||
</code></pre>
|
||||
|
||||
<p>Called by lightning during test loop. Make sure to use the @ptl.data_loader decorator, this ensures not calling this function until the data are needed.</p>
|
||||
<p>Called by lightning during test loop. Make sure to use the @pl.data_loader decorator, this ensures not calling this function until the data are needed.</p>
|
||||
<h5 id="return_5">Return</h5>
|
||||
<p>PyTorch DataLoader</p>
|
||||
<p><strong>Example</strong></p>
|
||||
<pre><code class="python">@ptl.data_loader
|
||||
<pre><code class="python">@pl.data_loader
|
||||
def test_dataloader(self):
|
||||
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (1.0,))])
|
||||
dataset = MNIST(root='/path/to/mnist/', train=False, transform=transform, download=True)
|
||||
|
||||
@@ -439,8 +439,8 @@
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#on_batch_end" title="on_batch_end" class="md-nav__link">
|
||||
on_batch_end
|
||||
<a href="#on_epoch_end" title="on_epoch_end" class="md-nav__link">
|
||||
on_epoch_end
|
||||
</a>
|
||||
|
||||
</li>
|
||||
@@ -450,6 +450,13 @@
|
||||
on_batch_start
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#on_batch_end" title="on_batch_end" class="md-nav__link">
|
||||
on_batch_end
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
@@ -567,8 +574,8 @@
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#on_batch_end" title="on_batch_end" class="md-nav__link">
|
||||
on_batch_end
|
||||
<a href="#on_epoch_end" title="on_epoch_end" class="md-nav__link">
|
||||
on_epoch_end
|
||||
</a>
|
||||
|
||||
</li>
|
||||
@@ -578,6 +585,13 @@
|
||||
on_batch_start
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#on_batch_end" title="on_batch_end" class="md-nav__link">
|
||||
on_batch_end
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
@@ -650,7 +664,7 @@ To enable a hook, simply override the method in your LightningModule and the tra
|
||||
</code></pre>
|
||||
|
||||
<hr />
|
||||
<h4 id="on_batch_end">on_batch_end</h4>
|
||||
<h4 id="on_epoch_end">on_epoch_end</h4>
|
||||
<p>Called in the training loop at the very end of the epoch. </p>
|
||||
<pre><code class="python">def on_epoch_end(self):
|
||||
# do something when the epoch ends
|
||||
@@ -663,6 +677,13 @@ To enable a hook, simply override the method in your LightningModule and the tra
|
||||
# do something when the batch starts
|
||||
</code></pre>
|
||||
|
||||
<hr />
|
||||
<h4 id="on_batch_end">on_batch_end</h4>
|
||||
<p>Called in the training loop after the batch. </p>
|
||||
<pre><code class="python">def on_batch_end(self):
|
||||
# do something when the batch ends
|
||||
</code></pre>
|
||||
|
||||
<hr />
|
||||
<h4 id="on_pre_performance_check">on_pre_performance_check</h4>
|
||||
<p>Called at the very beginning of the validation loop. </p>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20">
|
||||
<linearGradient id="b" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="a">
|
||||
<rect width="99" height="20" rx="3" fill="#fff"/>
|
||||
</mask>
|
||||
<g mask="url(#a)">
|
||||
<path fill="#555" d="M0 0h63v20H0z"/>
|
||||
<path fill="#4c1" d="M63 0h36v20H63z"/>
|
||||
<path fill="url(#b)" d="M0 0h99v20H0z"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
||||
<text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
||||
<text x="31.5" y="14">coverage</text>
|
||||
<text x="80" y="15" fill="#010101" fill-opacity=".3">99%</text>
|
||||
<text x="80" y="14">99%</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 901 B |
Reference in New Issue
Block a user