예제 #1
0
    6: 'walkinglow'
}

device = torch.device('cuda:3' if torch.cuda.is_available() else 'cpu')
data_path = './data/RADAR'

train_data, train_labels, test_data, test_labels = lib.RADARLoader(
    data_path, category, device, "")
train_data = lib.tensor_normalize(train_data)
train_labels = lib.tensor_normalize(train_labels)
test_data = lib.tensor_normalize(test_data)
test_labels = lib.tensor_normalize(test_labels)

gen = models.Generator_Conv(input_node_size=num_noise,
                            output_shape=data_shape).to(device)
disc = models.Discriminator_Conv(input_shape=data_shape).to(device)

lib.init_params(gen)
lib.init_params(disc)

optim_g = torch.optim.Adam(gen.parameters(), lr=1e-3, betas=(0, 0.9))
optim_d = torch.optim.Adam(disc.parameters(), lr=1e-3, betas=(0, 0.9))

for epoch in range(epochs):
    gen.train()
    disc.train()

    for i in range(1):
        for _train_data in train_data:
            x = _train_data.view(-1, 1, 128, 128)
            num_data = x.shape[0]
예제 #2
0
    ratio = 1 / (t + 1)  # current task's ratio
    solver_acc_dict[t] = {}
    pre_gen = None
    pre_solver = None
    if t > 0:
        pre_gen = gen
        pre_solver = deepcopy(solver.net)

        lib.model_grad_switch(pre_gen, False)
        lib.model_grad_switch(pre_solver, False)

    gen = models.Generator_Conv(input_node_size=num_noise,
                                output_shape=(1, 28, 28),
                                hidden_node_size=256,
                                hidden_node_num=2).to(device)
    disc = models.Discriminator_Conv(input_shape=(1, 28, 28)).to(device)

    lib.init_params(gen)
    lib.init_params(disc)

    TrainDataLoader = TrainDataLoaders[t]

    optim_g = torch.optim.Adam(gen.parameters(), lr=0.001, betas=(0, 0.9))
    optim_d = torch.optim.Adam(disc.parameters(), lr=0.001, betas=(0, 0.9))

    # Generator Training
    for epoch in range(gen_epochs):
        gen.train()
        disc.train()

        for i, (x, _) in enumerate(TrainDataLoader):