MCPcopy Index your code
hub / github.com/ActiveVisionLab/DFNet / train_on_epoch

Function train_on_epoch

script/dm/direct_pose_model.py:279–298  ·  view source on GitHub ↗

Perform 1 epoch of training with batch

(args, data_loaders, model, hwf, optimizer, half_res, device, **render_kwargs_test)

Source from the content-addressed store, hash-verified

277
278
279def train_on_epoch(args, data_loaders, model, hwf, optimizer, half_res, device, **render_kwargs_test):
280 ''' Perform 1 epoch of training with batch '''
281 model.train()
282 model = freeze_bn_layer_train(model)
283
284 # Prepare dataloaders for PoseNet, each batch contains (image, pose)
285 train_dl, val_dl, test_dl = data_loaders
286 total_loss = []
287 total_psnr = []
288
289 #### Core optimization loop #####
290 for data, pose, img_idx in train_dl:
291 # print("img_idx: {}, pose: {}".format(img_idx, pose) )
292 # training one step with batch_size = args.batch_size
293 loss, psnr = train_on_batch(args, data, model, pose, img_idx, hwf, optimizer, half_res, device, **render_kwargs_test)
294 total_loss.append(loss.item())
295 total_psnr.append(psnr.item())
296 total_loss_mean = np.mean(total_loss)
297 total_psnr_mean = np.mean(total_psnr)
298 return total_loss_mean, total_psnr_mean
299
300def save_val_result_7Scenes(args, epoch, val_dl, model, hwf, half_res, device, num_samples=1, **render_kwargs_test):
301 ''' Perform inference on a random val image and save the result '''

Callers 1

train_nerf_trackingFunction · 0.70

Calls 2

freeze_bn_layer_trainFunction · 0.90
train_on_batchFunction · 0.70

Tested by

no test coverage detected