8215a34d3203f45254b06a63271fe8010d351e6f,UnetTraining.py,,get_training_weights,#,102

Before Change


def get_training_weights(y_train, n_classes):
    weights = []
    for label in range(n_classes):
        weights.append(get_class_weights(y_train[:, label], n_classes=2))
    print("Training weights: {0}".format(weights))
    return np.array(weights)

After Change


def get_training_weights(training_generator, nb_training_samples, n_classes=2):
    counts = np.zeros((n_labels, n_classes))
    i = 0
    while i < nb_training_samples:
        _, y_train = training_generator.next()
        for label in range(n_labels):
            counts[label, :] += np.bincount(np.array(y_train[:, label].ravel(), dtype=np.uint8), minlength=n_classes)
        i += 1
    return counts_to_weights(counts)


def counts_to_weights(array):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: ellisdg/3DUnetCNN
Commit Name: 8215a34d3203f45254b06a63271fe8010d351e6f
Time: 2017-02-20
Author: david.ellis@unmc.edu
File Name: UnetTraining.py
Class Name:
Method Name: get_training_weights


Project Name: GoogleCloudPlatform/ml-on-gcp
Commit Name: bab61477e8d83c751509aeb91fc3b2e6ec743d93
Time: 2018-01-24
Author: yuhanliu@google.com
File Name: sklearn/hpsearch/gke_parallel.py
Class Name: GKEParallel
Method Name: _partition_search_spaces


Project Name: ntucllab/libact
Commit Name: 325fae8fbbc16b3c1ca40559bb2a9c783efaf440
Time: 2015-11-25
Author: yangarbiter@gmail.com
File Name: libact/query_strategies/active_learning_by_learning.py
Class Name: ActiveLearningByLearning
Method Name: make_query