Skip to content

Instantly share code, notes, and snippets.

@dvgodoy
Last active May 3, 2019 09:54
Show Gist options
  • Save dvgodoy/1551eb27a7c5f94df8534a1566219837 to your computer and use it in GitHub Desktop.
Save dvgodoy/1551eb27a7c5f94df8534a1566219837 to your computer and use it in GitHub Desktop.
losses = []
train_step = make_train_step(model, loss_fn, optimizer)
for epoch in range(n_epochs):
for x_batch, y_batch in train_loader:
# the dataset "lives" in the CPU, so do our mini-batches
# therefore, we need to send those mini-batches to the
# device where the model "lives"
x_batch = x_batch.to(device)
y_batch = y_batch.to(device)
loss = train_step(x_batch, y_batch)
losses.append(loss)
print(model.state_dict())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment