Examples of predicting testing data in for loop

Hi!

I am new to pytorch. I was able to successfully write the Dataset and Dataloader to preprocess, index, batch and shuffle my training dataset. I want to write code to create a for loop that runs through all epochs and trains on my training model, and tests on my testing data to predict labels (classification problem), and then output the labels in a csv file. Can anyone help me by linking tutorials, examples, starter code etc., that will be helpful to write the for loop for n epochs?

The MNIST example shown you a simple foop over your DataLoaders, while the ImageNet example gives you some other utilities (e.g. only storing the best checkpoint).

You can store the outputs as numpy arrays using output.detach().cpu().numpy() and store them as a csv using e.g. np.savetxt("preds.csv", output, delimiter=",") or pandas.

1 Like

Thank you for your reply!