convolutional neural networks #combine tensors from each batch test_preds torch cat((test_predspreds)dim= actual torch cat((actual,target),dim= return actual,test_preds #evalute model def evaluate(data_loader)model eval(loss correct for datatarget in data_loaderif torch cuda is_available()data data cuda(target target cuda(output model(dataloss + cross_entropy(outputtargetsize_ average=falsedata item(predicted output data max( keepdim=true)[ correct +(target reshape(- , =predicted reshape(- , )float(sum(loss /len(data_loader datasetprint('\naverage val loss{ }val accuracy{}/{({ }%)\nformatlosscorrectlen(data_loader dataset) correct len(data_loader dataset))with the important constructs in placewe can now create an instance of the model and define our criterion function and optimizeras demonstrated in listing -