if weights_file != -1: ActorCritic.load_state_dict(torch.load(weights_file)) # set up assistant Assistant = Assistant(directory=DIRECTORY, number_of_images=700) ##### SET UP TRAINING ##### ##### SET UP TRAINING ##### ##### SET UP TRAINING ##### for iteration in range(300000): # zero the graph gradient ActorCritic.zero_grad() # get a cropped image sample image = Assistant.get_cropped_sample()[0].unsqueeze(0).unsqueeze(0).to( device) # pass image through first module of FasteNet and get feature map F_map_1 = FasteNet.module_one(image) # based on feature map, scale to get inputs for AC AC_input = F.adaptive_max_pool2d(F_map_1[..., :32], 32) # based on feature map get reward and actions actions, estimated_reward = ActorCritic.forward(AC_input) # crop the feature map cropped_F_map = Assistant.crop_feature_map(actions[0].squeeze().item(), actions[1].squeeze().item(), F_map_1).to(device)