from __future__ import absolute_import, division, print_function, unicode_literals import json import math import time import os import torch import loaders import models import options import eval_simmc_agent as evaluation from tools import support # Arguments. args = options.read_command_line() # Dataloader. dataloader_args = { "single_pass": False, "shuffle": True, "data_read_path": args["train_data_path"], "get_retrieval_candidates": False } dataloader_args.update(args) train_loader = loaders.DataloaderSIMMC(dataloader_args) args.update(train_loader.get_data_related_arguments()) # Initiate the loader for val (DEV) data split. if args["eval_data_path"]: dataloader_args = { "single_pass": True,
gt_relevance_round_id - 1, :] ndcg.observe(output, gt_relevance) batch_idx += 1 dialog_encoder.train() print("tot eval batches", batch_idx) all_metrics = {} all_metrics.update(sparse_metrics.retrieve(reset=True)) all_metrics.update(ndcg.retrieve(reset=True)) return all_metrics if __name__ == '__main__': params = options.read_command_line() os.makedirs('checkpoints', exist_ok=True) if not os.path.exists(params['save_path']): os.mkdir(params['save_path']) viz = VisdomVisualize(enable=bool(params['enable_visdom']), env_name=params['visdom_env'], server=params['visdom_server'], port=params['visdom_server_port']) pprint.pprint(params) viz.addText(pprint.pformat(params, indent=4)) dataset = VisdialDataset(params) dataset.split = 'train' dataloader = DataLoader( dataset,