Exemplo n.º 1
0
def build_ParalCoAtt(task_name, dataset, params):
    # w_emb = WordEmbedding(dataset.dictionary.ntoken, 300, 0.0)
    # q_emb = QuestionEmbedding(300, num_hid, 1, False, 0.0)
    num_hid = params['num_hid']
    q_proj = FCNet([768, num_hid])
    bi_num_hid = num_hid * 2
    co_atts = nn.ModuleList([
        ParalCoAttention(dataset.v_dim,
                         num_hid,
                         num_hid,
                         inter_dims=params['scale'],
                         R=len(params['scale']))
        for _ in range(params['reasonSteps'])
    ])
    v_fusion_att = paraAttention(fuse_dim=dataset.v_dim,
                                 glimpses=params['sub_nums'],
                                 inputs_dim=dataset.v_dim,
                                 att_dim=num_hid)
    q_fusion_att = paraAttention(fuse_dim=num_hid,
                                 glimpses=params['sub_nums'],
                                 inputs_dim=num_hid,
                                 att_dim=num_hid)
    context_gate = FCNet([bi_num_hid, bi_num_hid])
    classifier = SimpleClassifier(bi_num_hid, num_hid * 2, 1, 0.5)
    return ActionModel(task_name, q_proj, co_atts, q_fusion_att, v_fusion_att,
                       context_gate, classifier)
def build_temporalAtt(task_name, dataset, params):
    # w_emb = WordEmbedding(dataset.dictionary.ntoken, 300, 0.0)
    # q_emb = QuestionEmbedding(300, num_hid, 1, False, 0.0)
    num_hid = params['num_hid']
    q_proj = FCNet([768, num_hid])
    bi_num_hid = num_hid*2
    co_att = CoAttention(dataset.v_dim, num_hid, bi_num_hid)
    v_fusion_att = paraAttention(fuse_dim=dataset.v_dim, glimpses=params['sub_nums'], inputs_dim=dataset.v_dim, att_dim=num_hid)
    q_fusion_att = paraAttention(fuse_dim=num_hid, glimpses=params['sub_nums'], inputs_dim=num_hid, att_dim=num_hid)
    classifier = SimpleClassifier(
        bi_num_hid, num_hid * 2, dataset.num_ans_candidates, 0.5)
    return FrameQAModel(task_name, q_proj, co_att, q_fusion_att, v_fusion_att, classifier)
Exemplo n.º 3
0
def build_temporalAtt(task_name, dataset, params):
    num_hid = params['num_hid']
    q_proj = FCNet([768, num_hid])
    bi_num_hid = num_hid * 2
    co_att = CoAttention(dataset.v_dim, num_hid, bi_num_hid)
    v_fusion_att = paraAttention(fuse_dim=dataset.v_dim,
                                 glimpses=params['sub_nums'],
                                 inputs_dim=dataset.v_dim,
                                 att_dim=num_hid)
    q_fusion_att = paraAttention(fuse_dim=num_hid,
                                 glimpses=params['sub_nums'],
                                 inputs_dim=num_hid,
                                 att_dim=num_hid)
    classifier = SimpleClassifier(2 * num_hid, num_hid * 2, 1, 0.5)
    return ActionModel(task_name, q_proj, co_att, q_fusion_att, v_fusion_att,
                       classifier)