lightning/pl_examples/bug_report/bug_report_model.ipynb

268 lines
15 KiB
Plaintext

{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"accelerator": "GPU",
"colab": {
"name": "bug_report_model.ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "rR4_BAUYs3Mb"
},
"source": [
"![image.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQYAAABSCAYAAAC2XXppAAAaWElEQVR4Ae2dh3dU1RbG3x/i0mXvoighgKgI2BtW7KKiSAcFFVBQmgqKil2UJzYUQXl2ERSRpoiIIJhMOiEQkpCQRup+63eSHS73zkxmkmFC2Wetm5m55ZTv7P3tcs5M/iNWDAFDwBDwIfAf32f7aAgYAoaAGDGYEBgChkAAASOGACR2whAwBIwYTAYMAUMggIARQwASO2EIGAJGDCYDhoAhEEDAiCEAiZ0wBAwBIwaTAUPAEAggYMQQgMROGAKGgBGDyYAhYAgEEDBiCEBiJwwBQ8CIwWTAEDAEAggYMQQgsROGgCFgxGAyYAgYAgEEjBgCkNgJQ8AQMGIwGTAEDIEAAkYMAUjshCFgCBgxmAwYAoZAAAEjhgAkdsIQMASMGEwGDAFDIIBAhxJDXW2j7NldL6WFdVJb0xjonJ0wBAyBjkGgQ4ihoUGkvLhONi6vlLlPFMg7j++Qv5aVS0VZvdTXG0F0jChYq4bAPgSSSwyNIpV7GiTzrypZMKNIJvXLlhHdQzKye0ie6pcjC57bKRkbqqW6vF4ajR/2zZK9MwSSjEDSiGFvVaMUZNbI93NL5Lk7cmRUz5AMS0mX4Rxdm47RF2TIs3fmynfv7pYdmTWyt7ohyXBYc4aAIQACB5wYyCMUF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p7rl19+uYwdO1Y2bdoUczuJvnHt2rUycOBAueKKK+T9999vEylqn+bMmeNwvOyyy2TFihWt4sdcgHmvXr1c21VVVVpV3K+vv/660C54o5CtkZK3AQhq586dcT3jfd77HsODfF188cXyyCOPeC8dMu+TTwyQQkq6TLo+R1YvLnOkQL4i79+9Mu7SrLg2Qbk8RJweA2yOwJ5//vnSqVMnOeecc+Tcc8+V8847z71y7owzzpAuXbrI4MGDBaWJ1Yrl5eXJ448/LmeffbZ07ty55aANDs7z6r125plnyr333uusZkdJzc8//+wU6rTTTpNXXnlFsPRtLS+88IIb31lnnSVLliwRvKhoZdWqVXLBBRfIKaecIm+88YZUVrY9VzR9+nShXeYSzy/WecO6z549W1577bVW+xttLHqtrKxMLrnkEjn11FPd3Or5Q+k1ucTQHD48dX2OrFpcJjXVTW4m34X44/ty912JuPMVbSQGhBEBuvHGG2XmzJnueO655+SJJ56Q/v37O+GGMEaMGCHbtm2LaU53794tixcvFgT02WeflWeeecYdDzzwgHTr1s21d8cdd8iUKVNark2dOlU++OADwQXvqAIx4OWcfvrp7SaGWbNmtRDsjz/+2KqiEUY9//zz8tRTT8ny5ctbvT8aRmAOsaekpDgPLFZieOyxx5wxGDRokLTHY9G+VVdXy0svveTGNG/ePD19SL0mlRj4evXUm3Nk9f/2kQJoVZc3yOezimTQOWnxJx/bQAy//vqrs1IIEESA61deXu4OrCUexX333eesT58+feSzzz6LycXEdUUoqM97fPzxx9K3b1/p2rWrU7yioqL9riOMhDhaeI9nE6tg63PRXqmPI1yBGAilIAasZklJiRsv98fjjlM3xADh4h3FQgy0AVZY2WjeBdf27t0brvst5yAG2gXnLVu2uL7H8hyeId4Sr4kgBjqEPDGm9nhALQPzvEE2wCHeefFUEdPbpBLDY30yZfmnpS2egvawuqJBFs8ulqFdQjKUL1l5k4utvW8HMSBAWCqvUtInBHXhwoXO8mDpp02b5rwGLBqkkZ6erl1veWWy0tLSBCUj+VZYWNhy7fPPP3euJUREHBxO+OgDzxBzf/PNN7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djUhBVq38/MlumdY/VwZ1SnO5gVjDi8HnprtfjJ5+e46sWFgqu/JqpY78YhLDBh2L/xWB1cN/zT4nFgGUgpwDFhFS5uDz4Rw+REKQcZN4VhyQwQOFwwEjBje4BpGqikbJ3bJX/vdKkVuJILzAA4hEEC5s6JQm4y/Pcv/lyuURKpKbR4g0MXbeEDhSEDiwxNCMIq5/eUm9/LuuSuY9uUNG9AjJA532X94cTh6hU5qMPj/D/U/K0PrmPMJB4CEcKcJg4zQEFIGkEIM2Rv6heHudrF+yR14elC+DO6e7JU7+yQz/T2L24G2yflm5lHZwHkH7a6+GwJGKQFKJQUGu3SuyI6dWfpq/W6bcnC1Tb8lxPxK7a3ut8EMtB0MeQftqr4bAkYhAhxCDA7pBpLqyUXZk18r2jBrZW2GEcCQKoI354ESg44ihGQ82JyVzg9LBOQ3WK0Pg4EKgw4nh4ILDemMIGAIgYMRgcmAIGAIBBIwYApDYCUPAEDBiMBkwBAyBAAJGDAFI7IQhYAgYMZgMGAKGQAABI4YAJHbCEDAEjBhMBgwBQyCAgBFDABI7YQgYAkYMJgOGgCEQQMCIIQCJnTAEDAEjBpMBQ8AQCCBgxBCAxE4YAoaAEYPJgCFgCAQQMGIIQGInDAFDwIjBZMAQMAQCCBgxBCCxE4aAIWDEYDJgCBgCAQSMGAKQ2AlDwBD4P9CuROTFaWXrAAAAAElFTkSuQmCC)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "i7XbLCXGkll9"
},
"source": [
"# The Boring Model\n",
"Replicate a bug you experience, using this model.\n",
"\n",
"[Remember! we're always available for support on Slack](https://join.slack.com/t/pytorch-lightning/shared_invite/zt-f6bl2l0l-JYMK3tbAgAmGRrlNr00f1A)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2LODD6w9ixlT"
},
"source": [
"---\n",
"## Setup env"
]
},
{
"cell_type": "code",
"metadata": {
"id": "zK7-Gg69kMnG"
},
"source": [
"%%capture\n",
"! pip install -qU pytorch-lightning"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "WvuSN5jEbY8P"
},
"source": [
"---\n",
"## Deps"
]
},
{
"cell_type": "code",
"metadata": {
"id": "w4_TYnt_keJi"
},
"source": [
"import os\n",
"\n",
"import torch\n",
"from torch.utils.data import DataLoader, Dataset\n",
"\n",
"from pytorch_lightning import LightningModule, Trainer"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "XrJDukwPtUnS"
},
"source": [
"---\n",
"## Data\n",
"Random data is best for debugging. If you needs special tensor shapes or batch compositions or dataloaders, modify as needed"
]
},
{
"cell_type": "code",
"metadata": {
"id": "hvgTiaZpkvwS"
},
"source": [
"class RandomDataset(Dataset):\n",
" def __init__(self, size, num_samples):\n",
" self.len = num_samples\n",
" self.data = torch.randn(num_samples, size)\n",
"\n",
" def __getitem__(self, index):\n",
" return self.data[index]\n",
"\n",
" def __len__(self):\n",
" return self.len"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "sxVlWjGhl02D"
},
"source": [
"num_samples = 10000"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "V7ELesz1kVQo"
},
"source": [
"class BoringModel(LightningModule):\n",
" def __init__(self):\n",
" super().__init__()\n",
" self.layer = torch.nn.Linear(32, 2)\n",
"\n",
" def forward(self, x):\n",
" return self.layer(x)\n",
"\n",
" def training_step(self, batch, batch_idx):\n",
" loss = self(batch).sum()\n",
" self.log(\"train_loss\", loss)\n",
" return {\"loss\": loss}\n",
"\n",
" def validation_step(self, batch, batch_idx):\n",
" loss = self(batch).sum()\n",
" self.log(\"valid_loss\", loss)\n",
"\n",
" def test_step(self, batch, batch_idx):\n",
" loss = self(batch).sum()\n",
" self.log(\"test_loss\", loss)\n",
"\n",
" def configure_optimizers(self):\n",
" return torch.optim.SGD(self.layer.parameters(), lr=0.1)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "ubvW3LGSupmt"
},
"source": [
"---\n",
"## Define the test"
]
},
{
"cell_type": "code",
"metadata": {
"id": "4Dk6Ykv8lI7X"
},
"source": [
"def run():\n",
" train_data = DataLoader(RandomDataset(32, 64), batch_size=2)\n",
" val_data = DataLoader(RandomDataset(32, 64), batch_size=2)\n",
" test_data = DataLoader(RandomDataset(32, 64), batch_size=2)\n",
"\n",
" model = BoringModel()\n",
" trainer = Trainer(\n",
" default_root_dir=os.getcwd(),\n",
" limit_train_batches=1,\n",
" limit_val_batches=1,\n",
" limit_test_batches=1,\n",
" num_sanity_val_steps=0,\n",
" max_epochs=1,\n",
" enable_model_summary=False,\n",
" )\n",
" trainer.fit(model, train_dataloaders=train_data, val_dataloaders=val_data)\n",
" trainer.test(model, dataloaders=test_data)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "4dPfTZVgmgxz"
},
"source": [
"---\n",
"## Run Test"
]
},
{
"cell_type": "code",
"metadata": {
"id": "AAtq1hwSmjKe"
},
"source": [
"run()"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "Flyi--SpvsJN"
},
"source": [
"---\n",
"## Environment\n",
"Run this to get the environment details"
]
},
{
"cell_type": "code",
"metadata": {
"id": "0-yvGFRoaDSi"
},
"source": [
"%%capture\n",
"! wget https://raw.githubusercontent.com/PyTorchLightning/pytorch-lightning/master/requirements/collect_env_details.py"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "quj4LUDgmFvj"
},
"source": [
"! python collect_env_details.py"
],
"execution_count": null,
"outputs": []
}
]
}