return trainer
trainer = train_model(model=model_a, loaders=[train_loader, validate_loader], save_dir="model_a")
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Prediction
// ----------------------------
// The trainer contains the trained model and we can do predictions.
// We use :code:`unwrap` to convert the results to numpy arrays.
trainer.eval_mode()
from inferno.utils.torch_utils import unwrap
for image, target in test_loader:
// transfer image to gpu
image = image.cuda() if USE_CUDA else image
// get batch size from image
batch_size = image.size()[0]
prediction = trainer.apply_model(image)
image = unwrap(image, as_numpy=True, to_cpu=True)
prediction = unwrap(prediction, as_numpy=True, to_cpu=True)
fig = pylab.figure()