예제 #1
0
    path_project = os.path.abspath('..')
    logger = SummaryWriter('../logs')

    args = args_parser()
    exp_details(args)

    device = 'cuda'

    train_dataset, test_dataset, user_groups = get_dataset(args)

    global_model = CNNCifar(args=args)
    V2 = CNNCifar(args=args)
    V2.to(device)

    global_model.to(device)
    global_model.train()
    print(global_model)

    global_weights = global_model.state_dict()

    train_loss, test_accuracy = [], []
    val_acc_list, net_list = [], []
    cv_loss, cv_acc = [], []
    print_every = 2
    val_loss_pre, counter = 0, 0
    x = 0
    my_sum = 0
    for epoch in tqdm(range(100)):
        x += 1
        local_weights, local_losses = [], []
        print(f'\n | Global Training Round : {epoch+1} |\n')
예제 #2
0
    path_project = os.path.abspath('..')
    logger = SummaryWriter('../logs')

    args = args_parser()
    exp_details(args)

    device = 'cuda'

    # load dataset and user groups
    train_dataset, test_dataset, user_groups = get_dataset(args)

    global_model = CNNCifar(args=args)

    new_global_model = CNNCifar(args=args)
    new_global_model.to(device)
    new_global_model.train()
    chafen_global_model = CNNCifar(args=args)
    chafen_global_model.to(device)
    chafen_global_model.train()
    chafen_local_model = CNNCifar(args=args)
    chafen_local_model.to(device)
    chafen_local_model.train()
    global_model.to(device)
    global_model.train()
    print(global_model)
    V2 = CNNCifar(args=args)
    V2.to(device)
    # copy weights
    global_weights = global_model.state_dict()
    new_global_weights = new_global_model.state_dict()
    chafen_global_weights = chafen_global_model.state_dict()