コード例 #1
0
l2 = 0.00001
lr = 0.0005

D_m = 300
D_g = 150
D_p = 150
D_e = 100
D_h = 100

D_a = 100  # concat attention

model = BiModel(D_m,
                D_g,
                D_p,
                D_e,
                D_h,
                n_classes=n_classes,
                listener_state=active_listener,
                context_attention=attention,
                dropout_rec=rec_dropout,
                dropout=dropout)
if cuda:
    model.cuda()
loss_weights = torch.FloatTensor([1.0, 1.0, 1.0])
if class_weight:
    loss_function = MaskedNLLLoss(
        loss_weights.cuda() if cuda else loss_weights)
else:
    loss_function = MaskedNLLLoss()
optimizer = optim.Adam(model.parameters(), lr=lr, weight_decay=l2)

train_loader, valid_loader, test_loader =\
コード例 #2
0
    batch_size = args.batch_size
    n_classes  = 6
    cuda       = args.cuda
    n_epochs   = args.epochs

    D_m = 100
    D_g = 150
    D_p = 150
    D_e = 100
    D_h = 100

    D_a = 100 # concat attention

    model = BiModel(D_m, D_g, D_p, D_e, D_h,
                    n_classes=n_classes,
                    listener_state=args.active_listener,
                    context_attention=args.attention,
                    dropout_rec=args.rec_dropout,
                    dropout=args.dropout)
    if cuda:
        model.cuda()
    loss_weights = torch.FloatTensor([
                                        1/0.086747,
                                        1/0.144406,
                                        1/0.227883,
                                        1/0.160585,
                                        1/0.127711,
                                        1/0.252668,
                                        ])
    if args.class_weight:
        loss_function  = MaskedNLLLoss(loss_weights.cuda() if cuda else loss_weights)
    else:
コード例 #3
0
    cuda = args.cuda
    n_epochs = args.epochs

    D_m = 100
    D_g = 500
    D_p = 500
    D_e = 300
    D_h = 300

    D_a = 100  # concat attention

    model = BiModel(D_m,
                    D_g,
                    D_p,
                    D_e,
                    D_h,
                    n_classes=n_classes,
                    listener_state=args.active_listener,
                    context_attention=args.attention,
                    dropout_rec=args.rec_dropout,
                    dropout=args.dropout)

    if args.pretrained != '':
        state_dict = torch.load(args.pretrained)
        model.load_state_dict(state_dict)
    if cuda:
        model.cuda()
    loss_weights = torch.FloatTensor([
        1 / 0.086747,
        1 / 0.144406,
        1 / 0.227883,
        1 / 0.160585,