def __init__(self, exp_name='cmu', input_n=10, output_n=10, dct_n=15, device='cuda:0', num_works=0, test_manner='all', debug_step=1):
    super(CMURunner, self).__init__()
    self.start_epoch = 1
    self.best_accuracy = 1000000000000000.0
    self.cfg = Config(exp_name=exp_name, input_n=input_n, output_n=output_n, dct_n=dct_n, device=device, num_works=num_works, test_manner=test_manner)
    print('\n================== Configs =================')
    pprint(vars(self.cfg), indent=4)
    print('==========================================\n')
    with open(os.path.join(self.cfg.ckpt_dir, 'config.txt'), 'w', encoding='utf-8') as f:
        f.write(str(self.cfg.__dict__))
    if (self.cfg.output_n == 25):
        self.model = MSRGCN(self.cfg.p_dropout, self.cfg.leaky_c, self.cfg.final_out_noden, input_feature=self.cfg.dct_n)
    elif (self.cfg.output_n == 10):
        self.model = MSRGCNShortTerm(self.cfg.p_dropout, self.cfg.leaky_c, self.cfg.final_out_noden, input_feature=self.cfg.dct_n)
    if (self.cfg.device != 'cpu'):
        self.model.cuda(self.cfg.device)
    print('>>> total params: {:.2f}M\n'.format((sum((p.numel() for p in self.model.parameters())) / 1000000.0)))
    self.lr = self.cfg.lr
    self.optimizer = optim.Adam(self.model.parameters(), lr=self.lr)
    (dct_m, i_dct_m) = get_dct_matrix(self.cfg.seq_len)
    self.dct_m = torch.from_numpy(dct_m).float()
    self.i_dct_m = torch.from_numpy(i_dct_m).float()
    if (self.cfg.device != 'cpu'):
        self.dct_m = self.dct_m.cuda(self.cfg.device, non_blocking=True)
        self.i_dct_m = self.i_dct_m.cuda(self.cfg.device, non_blocking=True)
    train_dataset = CMUMotionDataset(self.cfg.base_data_dir, actions='all', mode_name='train', input_n=self.cfg.input_n, output_n=self.cfg.output_n, dct_used=self.cfg.dct_n, split=0, sample_rate=2, down_key=[('p22', 'p12', self.cfg.Index2212), ('p12', 'p7', self.cfg.Index127), ('p7', 'p4', self.cfg.Index74)], test_manner=self.cfg.test_manner, global_max=0, global_min=0, device=self.cfg.device, debug_step=debug_step)
    print('train data shape {}'.format(train_dataset.gt_all_scales['p32'].shape[0]))
    self.train_loader = DataLoader(dataset=train_dataset, batch_size=self.cfg.train_batch_size, shuffle=True, num_workers=self.cfg.num_works, pin_memory=True)
    self.global_max = train_dataset.global_max
    self.global_min = train_dataset.global_min
    self.test_loader = dict()
    for act in define_actions_cmu('all'):
        test_dataset = CMUMotionDataset(self.cfg.base_data_dir, actions=act, mode_name='test', input_n=self.cfg.input_n, output_n=self.cfg.output_n, dct_used=self.cfg.dct_n, split=1, sample_rate=2, down_key=[('p22', 'p12', self.cfg.Index2212), ('p12', 'p7', self.cfg.Index127), ('p7', 'p4', self.cfg.Index74)], test_manner=self.cfg.test_manner, global_max=self.global_max, global_min=self.global_min, device=self.cfg.device, debug_step=debug_step)
        self.test_loader[act] = DataLoader(dataset=test_dataset, batch_size=self.cfg.test_batch_size, shuffle=False, num_workers=self.cfg.num_works, pin_memory=True)
        print('>>> test {} data {}'.format(act, test_dataset.gt_all_scales['p32'].shape[0]))
    self.summary = SummaryWriter(self.cfg.ckpt_dir)
def __init__(self, exp_name='cmu', input_n=10, output_n=10, dct_n=15, device='cuda:0', num_works=0, test_manner='all', debug_step=1):
    super(CMURunner, self).__init__()
    self.start_epoch = 1
    self.best_accuracy = 1000000000000000.0
    self.cfg = Config(exp_name=exp_name, input_n=input_n, output_n=output_n, dct_n=dct_n, device=device, num_works=num_works, test_manner=test_manner)
    print('\n================== Configs =================')
    pprint(vars(self.cfg), indent=4)
    print('==========================================\n')
    with open(os.path.join(self.cfg.ckpt_dir, 'config.txt'), 'w', encoding='utf-8') as f:
        f.write(str(self.cfg.__dict__))
    if (self.cfg.output_n == 25):
        self.model = MSRGCN(self.cfg.p_dropout, self.cfg.leaky_c, self.cfg.final_out_noden, input_feature=self.cfg.dct_n)
    elif (self.cfg.output_n == 10):
        self.model = MSRGCNShortTerm(self.cfg.p_dropout, self.cfg.leaky_c, self.cfg.final_out_noden, input_feature=self.cfg.dct_n)
    if (self.cfg.device != 'cpu'):
        self.model.cuda(self.cfg.device)
    print('>>> total params: {:.2f}M\n'.format((sum((p.numel() for p in self.model.parameters())) / 1000000.0)))
    self.lr = self.cfg.lr
    self.optimizer = optim.Adam(self.model.parameters(), lr=self.lr)
    (dct_m, i_dct_m) = get_dct_matrix(self.cfg.seq_len)
    self.dct_m = torch.from_numpy(dct_m).float()
    self.i_dct_m = torch.from_numpy(i_dct_m).float()
    if (self.cfg.device != 'cpu'):
        self.dct_m = self.dct_m.cuda(self.cfg.device, non_blocking=True)
        self.i_dct_m = self.i_dct_m.cuda(self.cfg.device, non_blocking=True)
    train_dataset = CMUMotionDataset(self.cfg.base_data_dir, actions='all', mode_name='train', input_n=self.cfg.input_n, output_n=self.cfg.output_n, dct_used=self.cfg.dct_n, split=0, sample_rate=2, down_key=[('p22', 'p12', self.cfg.Index2212), ('p12', 'p7', self.cfg.Index127), ('p7', 'p4', self.cfg.Index74)], test_manner=self.cfg.test_manner, global_max=0, global_min=0, device=self.cfg.device, debug_step=debug_step)
    print('train data shape {}'.format(train_dataset.gt_all_scales['p32'].shape[0]))
    self.train_loader = DataLoader(dataset=train_dataset, batch_size=self.cfg.train_batch_size, shuffle=True, num_workers=self.cfg.num_works, pin_memory=True)
    self.global_max = train_dataset.global_max
    self.global_min = train_dataset.global_min
    self.test_loader = dict()
    for act in define_actions_cmu('all'):
        test_dataset = CMUMotionDataset(self.cfg.base_data_dir, actions=act, mode_name='test', input_n=self.cfg.input_n, output_n=self.cfg.output_n, dct_used=self.cfg.dct_n, split=1, sample_rate=2, down_key=[('p22', 'p12', self.cfg.Index2212), ('p12', 'p7', self.cfg.Index127), ('p7', 'p4', self.cfg.Index74)], test_manner=self.cfg.test_manner, global_max=self.global_max, global_min=self.global_min, device=self.cfg.device, debug_step=debug_step)
        self.test_loader[act] = DataLoader(dataset=test_dataset, batch_size=self.cfg.test_batch_size, shuffle=False, num_workers=self.cfg.num_works, pin_memory=True)
        print('>>> test {} data {}'.format(act, test_dataset.gt_all_scales['p32'].shape[0]))
    self.summary = SummaryWriter(self.cfg.ckpt_dir)