Example #1
0
# 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)

print("Colearn Example Finished!")
Example #2
0
                              # "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)

print("Colearn Example Finished!")