ml_system.start()
    dataloader_params = {"location": data_folders[i]}
    ml_system.setup_ml(dataset_loader_name=args.dataloader_tag,
                       dataset_loader_parameters=json.dumps(dataloader_params),
                       model_arch_name=args.model_tag,
                       model_parameters=json.dumps({}))
    all_learner_models.append(ml_system)

# now colearn as usual!
set_equal_weights(all_learner_models)

# Train the model using Collective Learning
results = Results()
results.data.append(initial_result(all_learner_models))

plot = ColearnPlot(score_name="accuracy")

n_rounds = 10
vote_threshold = 0.5
for round_index in range(n_rounds):
    results.data.append(
        collective_learning_round(all_learner_models, vote_threshold,
                                  round_index))

    print_results(results)
    plot.plot_results_and_votes(results)

plot.block()

print("Colearn Example Finished!")
Example #2
0
    all_learner_models.append(learner)

# Ensure all learners starts with exactly same weights
set_equal_weights(all_learner_models)

# print a summary of the model architecture
summary(all_learner_models[0].model,
        input_size=(channels, width, height),
        device=str(device))

# Now we're ready to start collective learning
# Get initial accuracy
results = Results()
results.data.append(initial_result(all_learner_models))

plot = ColearnPlot(score_name=score_name)

# Do the training
for round_index in range(n_rounds):
    results.data.append(
        collective_learning_round(all_learner_models, vote_threshold,
                                  round_index))
    print_results(results)

    plot.plot_results(results)
    plot.plot_votes(results)

# Plot the final result with votes
plot.plot_results(results)
plot.plot_votes(results, block=True)
Example #3
0
    all_learner_models.append(
        XGBoostLearner(
            train_data=learner_train_data[i],
            train_labels=learner_train_labels[i],
            vote_data=learner_vote_data[i],
            vote_labels=learner_vote_labels[i],
            test_data=learner_test_data[i],
            test_labels=learner_test_labels[i],
            worker_id=i,
            xgb_params=params,
        ))

# Do collective learning
results = Results()
results.data.append(initial_result(all_learner_models))  # Get initial score

plot = ColearnPlot(score_name="mean square error")

for round_index in range(n_rounds):
    results.data.append(
        collective_learning_round(all_learner_models, vote_threshold,
                                  round_index))
    print_results(results)

    print_results(results)
    plot.plot_results_and_votes(results)

plot.block()

print("Colearn Example Finished!")
Example #4
0
    all_learner_models.append(
        KerasLearner(
            model=get_model(),
            train_loader=train_datasets[i],
            vote_loader=vote_datasets[i],
            test_loader=test_datasets[i],
            criterion="sparse_categorical_accuracy",
            minimise_criterion=False,
            model_evaluate_kwargs={"steps": vote_batches},
        ))

set_equal_weights(all_learner_models)

# Train the model using Collective Learning
results = Results()
results.data.append(initial_result(all_learner_models))

plot = ColearnPlot(score_name=all_learner_models[0].criterion)

for round_index in range(n_rounds):
    results.data.append(
        collective_learning_round(all_learner_models, vote_threshold,
                                  round_index))

    print_results(results)
    plot.plot_results_and_votes(results)

plot.block()

print("Colearn Example Finished!")
Example #5
0
                             num_test_batches=vote_batches,
                             vote_criterion=categorical_accuracy,
                             minimise_criterion=False)

    all_learner_models.append(learner)

# Ensure all learners starts with exactly same weights
set_equal_weights(all_learner_models)

summary(all_learner_models[0].model,
        input_size=(width, height),
        device=str(device))

# Train the model using Collective Learning
results = Results()
results.data.append(initial_result(all_learner_models))

plot = ColearnPlot(score_name=score_name)

for round_index in range(n_rounds):
    results.data.append(
        collective_learning_round(all_learner_models, vote_threshold,
                                  round_index))
    print_results(results)

    plot.plot_results_and_votes(results)

plot.block()

print("Colearn Example Finished!")
Example #6
0
            test_loader=test_datasets[i],
            model_fit_kwargs={"steps_per_epoch": steps_per_epoch,
                              # "class_weight": {0: 1, 1: 0.27}
                              },
            model_evaluate_kwargs={"steps": vote_batches},
            criterion="auc",
            minimise_criterion=False
        ))

set_equal_weights(all_learner_models)

results = Results()
# Get initial score
results.data.append(initial_result(all_learner_models))

plot = ColearnPlot(score_name=all_learner_models[0].criterion)

for round_index in range(n_rounds):
    results.data.append(
        collective_learning_round(all_learner_models,
                                  vote_threshold, round_index)
    )
    print_results(results)

    # then make an updating graph
    plot.plot_results(results)
    plot.plot_votes(results)

plot.plot_results(results, n_learners)
plot.plot_votes(results, block=True)