Skip to content

Instantly share code, notes, and snippets.

View georgestanley's full-sized avatar

Stanley George georgestanley

  • Albert-Ludwigs-Universität Freiburg
  • Freiburg
  • X @8pointsome1
View GitHub Profile
@georgestanley
georgestanley / spell_classifier.py
Created January 4, 2023 17:43
Pytorch code snippet to parallelly train on multiple GPUs
def initialize_model(hidden_dim, hidden_layers, lr, device):
# As in line 11, pass your model to nn.DataParallel class
# Pytorch would now parallelize your model trainig if multiple GPU's are found during initialization.
input_dim = alph_len * 3
hidden_dim = hidden_dim
layer_dim = hidden_layers
output_dim = 2
model = LSTMModel(input_dim, hidden_dim, layer_dim, output_dim, device)