Skip to content

Instantly share code, notes, and snippets.

@bkaankuguoglu
Created April 1, 2021 21:12
Show Gist options
  • Save bkaankuguoglu/5e51d3882f628ef77645cb303117168a to your computer and use it in GitHub Desktop.
Save bkaankuguoglu/5e51d3882f628ef77645cb303117168a to your computer and use it in GitHub Desktop.
def evaluate(self, test_loader, batch_size=1, n_features=1):
with torch.no_grad():
predictions = []
values = []
for x_test, y_test in test_loader:
x_test = x_test.view([batch_size, -1, n_features]).to(device)
y_test = y_test.to(device)
self.model.eval()
yhat = self.model(x_test)
predictions.append(yhat.to(device).detach().numpy())
values.append(y_test.to(device).detach().numpy())
return predictions, values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment