Beispiel #1
0
model.to(device)
optimizer = torch.optim.Adam(model.parameters(),
                             lr=learn_rate,
                             weight_decay=p.weight_decay)

writer = SummaryWriter(
    comment='model:exp2_3hops_lr:{}_shuffle:{}_seed:{}'.format(
        learn_rate, p.shuffle_dataset, p.random_seed))

max_roc_auc = 0

# ---- Training ----
print('Training...')
for epoch in range(1, epochs + 1):
    trainset.transform = Compose(
        (Center(), RandomRotate(90, epoch % 3), AddPositionalData(), TwoHop()))
    validset.transform = Compose(
        (Center(), RandomRotate(90, epoch % 3), AddPositionalData(), TwoHop()))
    train_loader = DataLoader(trainset,
                              shuffle=p.shuffle_dataset,
                              batch_size=p.batch_size)
    val_loader = DataLoader(validset,
                            shuffle=False,
                            batch_size=p.test_batch_size)

    learn_rate = optimizer.param_groups[0][
        'lr']  # for when it may be modified during run
    model.train()
    pred = torch.Tensor()
    tr_weights = torch.Tensor()
    loss = []
Beispiel #2
0
# ---- Training ----
print('Training...')
for epoch in range(1, epochs+1):
    # rotate the structures between epochs

    if 'pos' in p.dataset:  # Is there positional data in the features?
        degrees = 0
        if epoch > 200:
            if epoch < 700:
                degrees = 90*((epoch-200)/500)
            else:
                degrees = 90
        rotation_axis = axes[epoch % 3]  # only for structural data.
        trainset.transform = Compose((RemovePositionalData(),
                                      RandomRotate(degrees, axis=rotation_axis),
                                      AddPositionalData(),
                                      RemoveXYZ()))
        validset.transform = RemoveXYZ()

    # Using shape index data:
    trainset.transform = Compose((Center(), FaceAttributes(),
                                  NodeCurvature(), FaceToEdge(),
                                  TwoHop()), AddShapeIndex())
    validset.transform = Compose((Center(), FaceAttributes(),
                                  NodeCurvature(), FaceToEdge(),
                                  TwoHop()), AddShapeIndex())
    train_loader = DataListLoader(trainset, shuffle=p.shuffle_dataset, batch_size=p.batch_size)
    val_loader = DataListLoader(validset, shuffle=False, batch_size=p.test_batch_size)

    learn_rate = optimizer.param_groups[0]['lr']  # for when it may be modified during run
    # rotator()