Not sure how to save

Hi i create the face reconition CNN and im not sure how would i able to save it so i can load can anyone suggest me a way? .

this is my code

if __name__ == '__main__':

    #set_trace()
    args = edict({
        'operation' : 'train',
        'feature_file' : None,
         'result_sample_path' : None,
         'gpu' : 'GPU',
         'path_image_query' : None,
         'query_label' : 'Query label',
         'dataset' : None,
         'specific_dataset_folder_name' : 'lfw',
         'img_extension' : 'jpg',
         'preprocessing_method' : 'sphereface',
         'model_name' : 'mobiface',
         'batch_size' : 3,
         'image_query':'/content/drive/My Drive/recfaces13/recfaces/datasets/LFW',
         'train':True,
         'device':'cuda'
})
    print(args)

    # selecting the size of the crop based on the network
    if args.model_name == 'mobilefacenet' or args.model_name == 'sphereface':
        crop_size = (96, 112)
    elif args.model_name == 'mobiface' or args.model_name == 'shufflefacenet':
        crop_size = (112, 112)
    elif args.model_name == 'openface':
        crop_size = (96, 96)
    elif args.model_name == 'facenet':
        crop_size = (160, 160)
    else:
        raise NotImplementedError("Model " + args.model_name + " not implemented")

    if args.dataset is not None:
        # process whole dataset
        assert args.specific_dataset_folder_name is not None, 'To process a dataset, ' \
                                                              'the flag --specific_dataset_folder_name is required.'
        process_dataset(args.operation, args.model_name, args.batch_size,
                        args.dataset, args.specific_dataset_folder_name,
                        args.img_extension, args.preprocessing_method, crop_size,
                        args.result_sample_path, args.feature_file)

    elif args.operation == 'train':
      #set_trace()

      net = load_net('mobilefacenet', 'gpu')
      net = net.cuda()
      model_name=args.model_name
      
      dataset = LFW(args.image_query,args.specific_dataset_folder_name, args.img_extension, args.preprocessing_method, crop_size)
      dataloader = torch.utils.data.DataLoader(dataset, batch_size=1, shuffle=False, num_workers=2, drop_last=False)

      

      features = None

      if args.feature_file is not None and os.path.isfile(args.feature_file):
            features = scipy.io.loadmat(args.feature_file)      
      epoch = 2
      criterion = nn.CrossEntropyLoss()
      optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)
      train_loss = list()
      #set_trace()
      for i, data in enumerate(dataloader):
        
        inps, labs = data
        inps, labs = inps.cuda(args['device']), labs.cuda(args['device'])

        inps = Variable(inps).cuda(args['device'])
        labs = Variable(labs).cuda(args['device'])
        optimizer.zero_grad()
        outs = net(inps.permute(0, 3, 1, 2).float())
        soft_outs = F.softmax(outs, dim=1)
        prds = soft_outs.data.max(1)[1]
        loss = criterion(outs, labs)
        loss.backward()
        optimizer.step()
        prds = prds.cpu().numpy()
        inps_np = inps.detach().cpu().numpy()
        labs_np = labs.detach().cpu().numpy()
        train_loss.append(loss.data.item
                        ())
        print('[epoch %d], [iter %d / %d], [train loss %.5f]' % (epoch, i + 1, len(dataloader), np.asarray(train_loss).mean()))
```.


are there easy way to save that model? right now it run properly but i not sure how to recall this model so i can load it

This tutorial might be helpful, as it explains the recommended way of storing and loading the state_dicts. :slight_smile: