Skip to content

Instantly share code, notes, and snippets.

View sumedhpendurkar's full-sized avatar

Sumedh Pendurkar sumedhpendurkar

View GitHub Profile
import torch
import torch.nn as nn
from torch import optim
import torch.nn.functional as F
from torch.autograd import Variable
@sumedhpendurkar
sumedhpendurkar / encoder_pytorch.py
Last active March 13, 2019 17:45
Encoder Class for seq-2-seq modelling in PyTorch
class Encoder(nn.Module):
def __init__(self, input_size, hidden_size, bidirectional = True):
super(Encoder, self).__init__()
self.hidden_size = hidden_size
self.input_size = input_size
self.bidirectional = bidirectional
self.lstm = nn.LSTM(input_size, hidden_size, bidirectional = bidirectional)
def forward(self, inputs, hidden):