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)


def get_class_weights(labels_array, n_classes):
    counts = np.bincount(np.array(labels_array.ravel(), dtype=np.uint8), minlength=n_classes)

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):
    weights_list = []
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

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: yzhao062/pyod
Commit Name: f88ec970f95c3b1fb1f0d72ccf0069732e4a0510
Time: 2019-06-12
Author: yalmardeny@tssg,org
File Name: pyod/models/sod.py
Class Name: SOD
Method Name: _sod


Project Name: yzhao062/pyod
Commit Name: f5b2d7fecaea7886cc527ee16c292e1cd4bb736a
Time: 2019-05-29
Author: yalmardeny@tssg,org
File Name: pyod/models/sod.py
Class Name: SOD
Method Name: _sod