Esempio n. 1
0
    def __init__(self, game_config, device):
        self.training = False
        self.game_config = game_config
        self.is_e2e = game_config['rl-train']['e2e']

        self.doc_threshold = game_config['global']['guess_thre']
        self.force_guess = game_config['global']['force_guess']
        self.max_turns = game_config['global']['max_turns']

        # initial config
        self.turn_i = 1
        self.act_his = []
        self.cand_docs = None
        self.cand_names = []
        self.dialog_level_doc_dist = None
        self.dialog_level_act_dist = None

        # device
        self.enable_cuda = torch.cuda.is_available()
        self.device = device

        # state module
        self.state_module = self.get_state_module().to(self.device)

        # policy module
        self.policy_module = self.get_policy_module().to(self.device)

        self.load_parameters()

        logger.info('Filter-Module Params=%d' % count_parameters(self.state_module))
        logger.info('Diff-Module Params=%d' % count_parameters(self.policy_module))

        # optimizer
        self.optimizer = None

        # NLG with template
        template_path = game_config['dataset']['agent_template_path']
        self.nl_template = NLTemplate(template_path)
Esempio n. 2
0
    def __init__(self, config_file="/mnt/sdb/cjm/Match-LSTM/config/id19.yaml"):
        logger.info('------------MODEL TEST INPUT--------------')
        logger.info('loading config file...')
        #self.global_config = read_config("config/id19.yaml")
        self.global_config = read_config(config_file)

        # set random seed
        seed = self.global_config['global']['random_seed']
        torch.manual_seed(seed)

        torch.set_grad_enabled(
            False)  # make sure all tensors below have require_grad=False

        # set default gpu
        os.environ["CUDA_VISIBLE_DEVICES"] = str(
            self.global_config['test']["gpu_id"])

        enable_cuda = self.global_config['test']['enable_cuda']
        self.device = torch.device("cuda" if enable_cuda else "cpu")
        if torch.cuda.is_available() and not enable_cuda:
            logger.warning(
                "CUDA is avaliable, you can enable CUDA in config file")
        elif not torch.cuda.is_available() and enable_cuda:
            raise ValueError(
                "CUDA is not abaliable, please unable CUDA in config file")

        logger.info('reading squad dataset...')
        self.dataset = SquadDataset(self.global_config)

        logger.info('constructing model...')
        model_choose = self.global_config['global']['model']
        dataset_h5_path = self.global_config['data']['dataset_h5']
        if model_choose == 'base':
            model = BaseModel(
                dataset_h5_path,
                model_config=read_config('config/base_model.yaml'))
        elif model_choose == 'match-lstm':
            model = MatchLSTM(dataset_h5_path)
        elif model_choose == 'match-lstm+':
            model = MatchLSTMPlus(
                dataset_h5_path,
                self.global_config['preprocess']['use_domain_tag'])
        elif model_choose == 'r-net':
            model = RNet(dataset_h5_path)
        elif model_choose == 'm-reader':
            model = MReader(dataset_h5_path)
        else:
            raise ValueError('model "%s" in config file not recoginized' %
                             model_choose)
        model = model.to(self.device)
        model.eval()  # let training = False, make sure right dropout
        logging.info('model parameters count: %d' % count_parameters(model))

        # load model weight
        logger.info('loading model weight...')
        model_weight_path = self.global_config['data']['model_path']
        is_exist_model_weight = os.path.exists(model_weight_path)
        assert is_exist_model_weight, "not found model weight file on '%s'" % model_weight_path

        weight = torch.load(model_weight_path,
                            map_location=lambda storage, loc: storage)
        if enable_cuda:
            weight = torch.load(
                model_weight_path,
                map_location=lambda storage, loc: storage.cuda())
        model.load_state_dict(weight, strict=False)
        self.model = model

        self.nlp = spacy.load('en')
        self.metadata = {
            k: v.tolist()
            for k, v in self.dataset.meta_data.items()
        }
Esempio n. 3
0
def main():
    logger.info('------------MODEL TEST INPUT--------------')
    logger.info('loading config file...')
    global_config = read_config()

    # set random seed
    seed = global_config['global']['random_seed']
    torch.manual_seed(seed)

    torch.set_grad_enabled(False)  # make sure all tensors below have require_grad=False

    logger.info('reading squad dataset...')
    dataset = SquadDataset(global_config)

    logger.info('constructing model...')
    model_choose = global_config['global']['model']
    dataset_h5_path = global_config['data']['dataset_h5']
    if model_choose == 'base':
        model = BaseModel(dataset_h5_path,
                          model_config=read_config('config/base_model.yaml'))
    elif model_choose == 'match-lstm':
        model = MatchLSTM(dataset_h5_path)
    elif model_choose == 'match-lstm+':
        model = MatchLSTMPlus(dataset_h5_path)
    elif model_choose == 'r-net':
        model = RNet(dataset_h5_path)
    elif model_choose == 'm-reader':
        model = MReader(dataset_h5_path)
    else:
        raise ValueError('model "%s" in config file not recoginized' % model_choose)

    model.eval()  # let training = False, make sure right dropout
    logging.info('model parameters count: %d' % count_parameters(model))

    # load model weight
    logger.info('loading model weight...')
    model_weight_path = global_config['data']['model_path']
    is_exist_model_weight = os.path.exists(model_weight_path)
    assert is_exist_model_weight, "not found model weight file on '%s'" % model_weight_path

    weight = torch.load(model_weight_path, map_location=lambda storage, loc: storage)
    model.load_state_dict(weight, strict=False)

    # manual input qa
    context = "In 1870, Tesla moved to Karlovac, to attend school at the Higher Real Gymnasium, where he was " \
             "profoundly influenced by a math teacher Martin Sekuli\u0107.:32 The classes were held in German, " \
             "as it was a school within the Austro-Hungarian Military Frontier. Tesla was able to perform integral " \
             "calculus in his head, which prompted his teachers to believe that he was cheating. He finished a " \
             "four-year term in three years, graduating in 1873.:33 "
    question1 = "What language were classes held in at Tesla's school?"
    answer1 = ["German"]

    question2 = "Who was Tesla influenced by while in school?"
    answer2 = ["Martin Sekuli\u0107"]

    question3 = "Why did Tesla go to Karlovac?"
    answer3 = ["attend school at the Higher Real Gymnasium", 'to attend school']

    # change here to select questions
    question = question1
    answer = answer1[0]

    # preprocess
    nlp = spacy.load('en')
    context_doc = DocText(nlp, context, global_config['preprocess'])
    question_doc = DocText(nlp, question, global_config['preprocess'])
    context_doc.update_em(question_doc)
    question_doc.update_em(context_doc)

    context_token = context_doc.token
    question_token = question_doc.token

    context_id_char = to_long_tensor(dataset.sentence_char2id(context_token))
    question_id_char = to_long_tensor(dataset.sentence_char2id(question_token))

    context_id, context_f = context_doc.to_id(dataset.meta_data)
    question_id, question_f = question_doc.to_id(dataset.meta_data)

    bat_input = [context_id, question_id, context_id_char, question_id_char, context_f, question_f]
    bat_input = [x.unsqueeze(0) if x is not None else x for x in bat_input]

    out_ans_prop, out_ans_range, vis_param = model.forward(*bat_input)
    out_ans_range = out_ans_range.numpy()

    start = out_ans_range[0][0]
    end = out_ans_range[0][1] + 1

    out_answer_id = context_id[start:end]
    out_answer = dataset.sentence_id2word(out_answer_id)

    logging.info('Predict Answer: ' + ' '.join(out_answer))

    # to show on visdom
    s = 0
    e = 48

    x_left = vis_param['match']['left']['alpha'][0, :, s:e].numpy()
    x_right = vis_param['match']['right']['alpha'][0, :, s:e].numpy()

    x_left_gated = vis_param['match']['left']['gated'][0, :, s:e].numpy()
    x_right_gated = vis_param['match']['right']['gated'][0, :, s:e].numpy()

    draw_heatmap_sea(x_left,
                     xlabels=context_token[s:e],
                     ylabels=question_token,
                     answer=answer,
                     save_path='data/test-left.png',
                     bottom=0.45)
    draw_heatmap_sea(x_right,
                     xlabels=context_token[s:e],
                     ylabels=question_token,
                     answer=answer,
                     save_path='data/test-right.png',
                     bottom=0.45)

    enable_self_match = False
    if enable_self_match:
        x_self_left = vis_param['self']['left']['alpha'][0, s:e, s:e].numpy()
        x_self_right = vis_param['self']['right']['alpha'][0, s:e, s:e].numpy()

        draw_heatmap_sea(x_self_left,
                         xlabels=context_token[s:e],
                         ylabels=context_token[s:e],
                         answer=answer,
                         save_path='data/test-self-left.png',
                         inches=(11, 11),
                         bottom=0.2)
        draw_heatmap_sea(x_self_right,
                         xlabels=context_token[s:e],
                         ylabels=context_token[s:e],
                         answer=answer,
                         save_path='data/test-self-right.png',
                         inches=(11, 11),
                         bottom=0.2)
Esempio n. 4
0
def main():
    logger.info('------------MODEL TEST INPUT--------------')
    logger.info('loading config file...')

    # manual set
    global_config = read_config('config/global_config.yaml')

    # set random seed
    seed = global_config['global']['random_seed']
    torch.manual_seed(seed)

    torch.set_grad_enabled(
        False)  # make sure all tensors below have require_grad=False

    logger.info('reading dataset...')
    dataset = Dataset(global_config)

    logger.info('constructing model...')
    dataset_h5_path = global_config['data']['dataset_h5']
    model = MatchLSTMPlus(dataset_h5_path)
    model.eval()  # let training = False, make sure right dropout

    logging.info('model parameters count: %d' % count_parameters(model))

    model_rerank = None
    rank_k = global_config['global']['rank_k']
    if global_config['global']['enable_rerank']:
        model_rerank = ReRanker(dataset_h5_path)
        model_rerank.eval()

        logging.info('rerank model parameters count: %d' %
                     count_parameters(model_rerank))

    # load model weight
    logger.info('loading model weight...')
    model_weight_path = global_config['data']['model_path']
    is_exist_model_weight = os.path.exists(model_weight_path)
    assert is_exist_model_weight, "not found model weight file on '%s'" % model_weight_path

    weight = torch.load(model_weight_path,
                        map_location=lambda storage, loc: storage)
    model.load_state_dict(weight, strict=False)

    if global_config['global']['enable_rerank']:
        rerank_weight_path = global_config['data']['rerank_model_path']
        assert os.path.exists(
            rerank_weight_path
        ), "not found rerank model weight file on '%s'" % rerank_weight_path
        logger.info('loading rerank model weight...')
        weight = torch.load(rerank_weight_path,
                            map_location=lambda storage, loc: storage)
        model_rerank.load_state_dict(weight, strict=False)

    context = "《战国无双3》()是由光荣和ω-force开发的战国无双系列的正统第三续作。本作以三大故事为主轴,分别是以武田信玄等人为主的《关东三国志》,织田信长等人为主的《战国三杰》,石田三成等人为主的《关原的年轻武者》,丰富游戏内的剧情。此部份专门介绍角色,欲知武器情报、奥义字或擅长攻击类型等,请至战国无双系列1.由于乡里大辅先生因故去世,不得不寻找其他声优接手。从猛将传 and Z开始。2.战国无双 编年史的原创男女主角亦有专属声优。此模式是任天堂游戏谜之村雨城改编的新增模式。本作中共有20张战场地图(不含村雨城),后来发行的猛将传再新增3张战场地图。但游戏内战役数量繁多,部分地图会有兼用的状况,战役虚实则是以光荣发行的2本「战国无双3 人物真书」内容为主,以下是相关介绍。(注:前方加☆者为猛将传新增关卡及地图。)合并本篇和猛将传的内容,村雨城模式剔除,战国史模式可直接游玩。主打两大模式「战史演武」&「争霸演武」。系列作品外传作品"
    question1 = "《战国无双3》是由哪两个公司合作开发的?"
    answer1 = ['光荣和ω-force']

    question2 = '男女主角亦有专属声优这一模式是由谁改编的?'
    answer2 = ['村雨城', '任天堂游戏谜之村雨城']

    question3 = '战国史模式主打哪两个模式?'
    answer3 = ['「战史演武」&「争霸演武」']

    # change here to select questions
    question = question2
    answer = answer2[0]

    # preprocess
    preprocess_config = global_config['preprocess']
    context_doc = DocTextCh(context, preprocess_config)
    question_doc = DocTextCh(question, preprocess_config)

    link_char = ''
    # mpl.rcParams['font.sans-serif'] = ['Microsoft YaHei']
    mpl.rcParams['font.sans-serif'] = ['SimHei']

    context_doc.update_em(question_doc)
    question_doc.update_em(context_doc)

    context_token = context_doc.token
    question_token = question_doc.token

    context_id_char = None
    question_id_char = None
    if preprocess_config['use_char']:
        context_id_char = to_long_tensor(
            dataset.sentence_char2id(context_token))
        question_id_char = to_long_tensor(
            dataset.sentence_char2id(question_token))

    context_id, context_f = context_doc.to_id(dataset.meta_data)
    question_id, question_f = question_doc.to_id(dataset.meta_data)

    bat_input = [
        context_id, question_id, context_id_char, question_id_char, context_f,
        question_f
    ]
    bat_input = [x.unsqueeze(0) if x is not None else x for x in bat_input]

    # predict
    out_ans_prop, out_ans_range, vis_param = model.forward(*bat_input)
    if model_rerank is not None:
        cand_ans_range = beam_search(out_ans_prop, k=rank_k)
        cand_score, out_ans_range = model_rerank(bat_input[0], bat_input[1],
                                                 cand_ans_range)

    out_ans_range = out_ans_range.numpy()

    start = out_ans_range[0][0]
    end = out_ans_range[0][1] + 1

    out_answer_id = context_id[start:end]
    out_answer = dataset.sentence_id2word(out_answer_id)

    logging.info('Predict Answer: ' + link_char.join(out_answer))

    # to show on visdom
    s = 0
    e = 48

    x_left = vis_param['match']['left']['alpha'][0, :, s:e].numpy()
    x_right = vis_param['match']['right']['alpha'][0, :, s:e].numpy()

    x_left_gated = vis_param['match']['left']['gated'][0, :, s:e].numpy()
    x_right_gated = vis_param['match']['right']['gated'][0, :, s:e].numpy()

    draw_heatmap_sea(x_left,
                     xlabels=context_token[s:e],
                     ylabels=question_token,
                     answer=answer,
                     save_path='data/test-left.png',
                     bottom=0.2)
    draw_heatmap_sea(x_right,
                     xlabels=context_token[s:e],
                     ylabels=question_token,
                     answer=answer,
                     save_path='data/test-right.png',
                     bottom=0.2)
Esempio n. 5
0
def main():
    logger.info('------------MODEL TEST INPUT--------------')
    logger.info('loading config file...')
    global_config = read_config()

    # set random seed
    seed = global_config['global']['random_seed']
    torch.manual_seed(seed)

    torch.set_grad_enabled(
        False)  # make sure all tensors below have require_grad=False

    logger.info('reading squad dataset...')
    dataset = SquadDataset(global_config)

    logger.info('constructing model...')
    model_choose = global_config['global']['model']
    dataset_h5_path = global_config['data']['dataset_h5']
    if model_choose == 'base':
        model = BaseModel(dataset_h5_path,
                          model_config=read_config('config/base_model.yaml'))
    elif model_choose == 'match-lstm':
        model = MatchLSTM(dataset_h5_path)
    elif model_choose == 'match-lstm+':
        model = MatchLSTMPlus(dataset_h5_path)
    elif model_choose == 'r-net':
        model = RNet(dataset_h5_path)
    elif model_choose == 'm-reader':
        model = MReader(dataset_h5_path)
    else:
        raise ValueError('model "%s" in config file not recoginized' %
                         model_choose)

    model.eval()  # let training = False, make sure right dropout
    logging.info('model parameters count: %d' % count_parameters(model))

    # load model weight
    logger.info('loading model weight...')
    model_weight_path = global_config['data']['model_path']
    is_exist_model_weight = os.path.exists(model_weight_path)
    assert is_exist_model_weight, "not found model weight file on '%s'" % model_weight_path

    weight = torch.load(model_weight_path,
                        map_location=lambda storage, loc: storage)
    model.load_state_dict(weight, strict=False)

    # manual input qa
    context = "In 1870, Tesla moved to Karlovac, to attend school at the Higher Real Gymnasium, where he was " \
             "profoundly influenced by a math teacher Martin Sekuli\u0107.:32 The classes were held in German, " \
             "as it was a school within the Austro-Hungarian Military Frontier. Tesla was able to perform integral " \
             "calculus in his head, which prompted his teachers to believe that he was cheating. He finished a " \
             "four-year term in three years, graduating in 1873.:33 "
    question1 = "What language were classes held in at Tesla's school?"
    answer1 = ["German"]

    question2 = "Who was Tesla influenced by while in school?"
    answer2 = ["Martin Sekuli\u0107"]

    question3 = "Why did Tesla go to Karlovac?"
    answer3 = [
        "attend school at the Higher Real Gymnasium", 'to attend school'
    ]

    # change here to select questions
    question = question1
    answer = answer1[0]

    # preprocess
    nlp = spacy.load('en')
    context_doc = DocText(nlp, context, global_config['preprocess'])
    question_doc = DocText(nlp, question, global_config['preprocess'])
    context_doc.update_em(question_doc)
    question_doc.update_em(context_doc)

    context_token = context_doc.token
    question_token = question_doc.token

    context_id_char = to_long_tensor(dataset.sentence_char2id(context_token))
    question_id_char = to_long_tensor(dataset.sentence_char2id(question_token))

    context_id, context_f = context_doc.to_id(dataset.meta_data)
    question_id, question_f = question_doc.to_id(dataset.meta_data)

    bat_input = [
        context_id, question_id, context_id_char, question_id_char, context_f,
        question_f
    ]
    bat_input = [x.unsqueeze(0) if x is not None else x for x in bat_input]

    out_ans_prop, out_ans_range, vis_param = model.forward(*bat_input)
    out_ans_range = out_ans_range.numpy()

    start = out_ans_range[0][0]
    end = out_ans_range[0][1] + 1

    out_answer_id = context_id[start:end]
    out_answer = dataset.sentence_id2word(out_answer_id)

    logging.info('Predict Answer: ' + ' '.join(out_answer))

    # to show on visdom
    s = 0
    e = 48

    x_left = vis_param['match']['left']['alpha'][0, :, s:e].numpy()
    x_right = vis_param['match']['right']['alpha'][0, :, s:e].numpy()

    x_left_gated = vis_param['match']['left']['gated'][0, :, s:e].numpy()
    x_right_gated = vis_param['match']['right']['gated'][0, :, s:e].numpy()

    draw_heatmap_sea(x_left,
                     xlabels=context_token[s:e],
                     ylabels=question_token,
                     answer=answer,
                     save_path='data/test-left.png',
                     bottom=0.45)
    draw_heatmap_sea(x_right,
                     xlabels=context_token[s:e],
                     ylabels=question_token,
                     answer=answer,
                     save_path='data/test-right.png',
                     bottom=0.45)

    enable_self_match = False
    if enable_self_match:
        x_self_left = vis_param['self']['left']['alpha'][0, s:e, s:e].numpy()
        x_self_right = vis_param['self']['right']['alpha'][0, s:e, s:e].numpy()

        draw_heatmap_sea(x_self_left,
                         xlabels=context_token[s:e],
                         ylabels=context_token[s:e],
                         answer=answer,
                         save_path='data/test-self-left.png',
                         inches=(11, 11),
                         bottom=0.2)
        draw_heatmap_sea(x_self_right,
                         xlabels=context_token[s:e],
                         ylabels=context_token[s:e],
                         answer=answer,
                         save_path='data/test-self-right.png',
                         inches=(11, 11),
                         bottom=0.2)
Esempio n. 6
0
def main():
    logger.info('------------Match-LSTM TEST INPUT--------------')
    logger.info('loading config file...')
    global_config = read_config()

    # set random seed
    seed = global_config['model']['global']['random_seed']
    torch.manual_seed(seed)

    torch.no_grad()  # make sure all tensors below have require_grad=False

    logger.info('reading squad dataset...')
    dataset = SquadDataset(global_config)

    logger.info('constructing model...')
    model = MatchLSTMModel(global_config)
    model.eval()  # let training = False, make sure right dropout

    logging.info('model parameters count: %d' % count_parameters(model))

    # load model weight
    logger.info('loading model weight...')
    model_weight_path = global_config['data']['model_path']
    is_exist_model_weight = os.path.exists(model_weight_path)
    assert is_exist_model_weight, "not found model weight file on '%s'" % model_weight_path

    weight = torch.load(model_weight_path,
                        map_location=lambda storage, loc: storage)
    model.load_state_dict(weight, strict=False)

    # manual input qa
    context = "In 1870, Tesla moved to Karlovac, to attend school at the Higher Real Gymnasium, where he was " \
             "profoundly influenced by a math teacher Martin Sekuli\u0107.:32 The classes were held in German, " \
             "as it was a school within the Austro-Hungarian Military Frontier. Tesla was able to perform integral " \
             "calculus in his head, which prompted his teachers to believe that he was cheating. He finished a " \
             "four-year term in three years, graduating in 1873.:33 "
    question1 = "What language were classes held in at Tesla's school?"
    answer1 = ["German"]

    question2 = "Who was Tesla influenced by while in school?"
    answer2 = ["Martin Sekuli\u0107"]

    question3 = "Why did Tesla go to Karlovac?"
    answer3 = [
        "attend school at the Higher Real Gymnasium", 'to attend school'
    ]

    # change here to select questions
    question = question1
    answer = answer1[0]

    # preprocess
    context_token = nltk.word_tokenize(context)
    question_token = nltk.word_tokenize(question)

    a = np.array(context_token)

    context_id = dataset.sentence_word2id(context_token)
    question_id = dataset.sentence_word2id(question_token)

    context_id_char = dataset.sentence_char2id(context_token)
    question_id_char = dataset.sentence_char2id(question_token)

    context_var, question_var, context_var_char, question_var_char = [
        to_long_tensor(x).unsqueeze(0)
        for x in [context_id, question_id, context_id_char, question_id_char]
    ]

    out_ans_prop, out_ans_range, vis_param = model.forward(
        context_var, question_var, context_var_char, question_var_char)
    out_ans_range = out_ans_range.cpu().data.numpy()

    start = out_ans_range[0][0]
    end = out_ans_range[0][1] + 1

    out_answer_id = context_id[start:end]
    out_answer = dataset.sentence_id2word(out_answer_id)

    logging.info('Predict Answer: ' + ' '.join(out_answer))

    # to show on visdom
    s = 0
    e = 48

    x_left = vis_param['match']['left'][0, :, s:e].cpu().data.numpy()
    x_right = vis_param['match']['right'][0, :, s:e].cpu().data.numpy()

    draw_heatmap_sea(x_left,
                     xlabels=context_token[s:e],
                     ylabels=question_token,
                     answer=answer,
                     save_path='data/test-left.png',
                     bottom=0.45)
    draw_heatmap_sea(x_right,
                     xlabels=context_token[s:e],
                     ylabels=question_token,
                     answer=answer,
                     save_path='data/test-right.png',
                     bottom=0.45)

    if global_config['model']['interaction']['enable_self_match']:
        x_self_left = vis_param['self']['left'][0, s:e, s:e].cpu().data.numpy()
        x_self_right = vis_param['self']['right'][0, s:e,
                                                  s:e].cpu().data.numpy()

        draw_heatmap_sea(x_self_left,
                         xlabels=context_token[s:e],
                         ylabels=context_token[s:e],
                         answer=answer,
                         save_path='data/test-self-left.png',
                         inches=(11, 11),
                         bottom=0.2)
        draw_heatmap_sea(x_self_right,
                         xlabels=context_token[s:e],
                         ylabels=context_token[s:e],
                         answer=answer,
                         save_path='data/test-self-right.png',
                         inches=(11, 11),
                         bottom=0.2)
Esempio n. 7
0
    'loss'] == 'wgan' and discriminator_loss_hyperparams == 'wgan'

# Initialize generator, discriminator and RoI generator
generator = Generator(**config.gen_hyperparams)
discriminator = Discriminator(dis_n_features, is_wgan, noise_hyperparams)

roi = RoI(image_size, locals()[roi_function], len(train_data))
roi_loader = DataLoader(roi,
                        batch_size=batch_size,
                        shuffle=False,
                        num_workers=5)

from utils.functions import count_parameters
if print_summary:
    print('Generator:')
    count_parameters(generator)
    #summary(generator, [(gen_n_input, 1, 1), (1, 64, 64)], device='cpu')
    print('Discriminator')
    count_parameters(discriminator)
    #summary(discriminator, (3, 64, 64), device='cpu')

# Initialize weights
if chkpname_dis == None and chkpname_gen == None:
    generator.apply(weights_init)
    discriminator.apply(weights_init)

# Optimizers
optimizer_G = torch.optim.Adam([{
    'params': generator.parameters()
}, {
    'params': discriminator.q_net.parameters()