This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# model | |
class Net(LightningModule): | |
def __init__(self): | |
self.layer_1 = torch.nn.Linear(28 * 28, 128) | |
self.layer_2 = torch.nn.Linear(128, 10) | |
def forward(self, x): | |
x = x.view(x.size(0), -1) | |
x = self.layer_1(x) | |
x = F.relu(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# model | |
class Net(nn.Module): | |
def __init__(self): | |
self.layer_1 = torch.nn.Linear(28 * 28, 128) | |
self.layer_2 = torch.nn.Linear(128, 10) | |
def forward(self, x): | |
x = x.view(x.size(0), -1) | |
x = self.layer_1(x) | |
x = F.relu(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# model | |
class Net(LightningModule): | |
def __init__(self): | |
self.layer_1 = torch.nn.Linear(28 * 28, 128) | |
self.layer_2 = torch.nn.Linear(128, 10) | |
def forward(self, x): | |
x = x.view(x.size(0), -1) | |
x = self.layer_1(x) | |
x = F.relu(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# model | |
class Net(nn.Module): | |
def __init__(self): | |
self.layer_1 = torch.nn.Linear(28 * 28, 128) | |
self.layer_2 = torch.nn.Linear(128, 10) | |
def forward(self, x): | |
x = x.view(x.size(0), -1) | |
x = self.layer_1(x) | |
x = F.relu(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def training_step(self, batch, batch_idx): | |
x, y = batch | |
# define your own forward and loss calculation | |
hidden_states = self.encoder(x) | |
# even as complex as a seq-2-seq + attn model | |
# (this is just a toy, non-working example to illustrate) | |
start_token = '<SOS>' | |
last_hidden = torch.zeros(...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch import nn | |
import pytorch_lightning as pl | |
from torch.utils.data import DataLoader, random_split | |
from torch.nn import functional as F | |
from torchvision.datasets import MNIST | |
from torchvision import datasets, transforms | |
import os | |
class LightningMNISTClassifier(pl.LightningModule): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch import nn | |
import pytorch_lightning as pl | |
from torch.utils.data import DataLoader, random_split | |
from torch.nn import functional as F | |
from torchvision.datasets import MNIST | |
from torchvision import datasets, transforms | |
import os | |
# ----------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models | |
encoder = Encoder() | |
decoder = Decoder() | |
# data are images | |
image = data.x | |
# encode and decode | |
z = encoder(image) | |
x_hat = decoder(z) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mu = [2 0]; | |
sigma = [1 0; 0 1]; | |
mu10 = [-2 0]; | |
sigma10 = [1 0; 0 1]; | |
mu2 = [-4 -4]; | |
sigma2 = [1 0; 0 1]; | |
mu3 = [4 4]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -l | |
# SLURM SUBMIT SCRIPT | |
#SBATCH --nodes=4 | |
#SBATCH --gres=gpu:4 | |
#SBATCH --ntasks-per-node=4 | |
#SBATCH --mem=0 | |
#SBATCH --time=0-02:00:00 | |
# activate conda env |