February 2018
Intermediate to advanced
262 pages
6h 59m
English
We pass the data from the train and validation data loaders through the model and store the results of the model in a list for further computation. By calculating the pre-convoluted features, we can save a lot of time in training the model, as we will not be calculating these features in every iteration. In the following code, we calculate the pre-convulted features:
#For training data# Stores the labels of the train datatrn_labels = [] # Stores the pre convoluted features of the train datatrn_features = [] #Iterate through the train data and store the calculated features and the labelsfor d,la in train_loader: o = m(Variable(d.cuda())) o = o.view(o.size(0),-1) trn_labels.extend(la) trn_features.extend(o.cpu().data) ...