Ad

Saturday, March 2, 2019

Pytorch Cheatsheet for beginners

train_loader, test_loader in python code pattern

train_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, num_workers=num_workers)
test_loader = torch.utils.data.DataLoader(test_data, batch_size=batch_size, num_workers=num_workers)

Pytorch dataloader helps load data in batches such as images.

Flavors of Pytorch Model Initialization

Functional

import torch.nn as nn
import torch.nn.functional as F

Object Oriented OOP

class Autoencoder(nn.Module):
    def __init__(self, encoding_dim):
        super(Autoencoder, self).__init__()
        ## encoder ##
        
        ## decoder ##
        

    def forward(self, x):
        # define feedforward behavior 
        # and scale the *output* layer with a sigmoid activation function
        
        return x

Best Practice:
Pytorch do sanity check load checkpoint and make sure everything worked. Imshow() the output image make sure it is the desired output. Do sanity check, visual check.

No comments:

Post a Comment

Applying for jobs at the Lending Club

We tried to figure out Lending Club 's tech stack for 2019. Our analysis shows Lending Club asks for skills in Python, Tableau, SQL and ...