f8df6021a1343d511d4c9b4c108ec5b683ce5487,modAL/batch.py,,ranked_batch,#Any#Any#Any#Any#,103

Before Change



    // Add uncertainty scores to our unlabeled data, and keep a copy of our unlabeled data.
    unlabeled_uncertainty = np.concatenate((unlabeled, np.expand_dims(uncertainty_scores, axis=1)), axis=1)
    unlabeled_uncertainty_copy = np.copy(unlabeled_uncertainty)

    // Define our record container and the maximum number of records to sample.
    instance_index_ranking = []
    ceiling = np.minimum(unlabeled.shape[0], n_instances)

    // TODO (dataframing) is there a better way to do this? Inherently sequential.
    for _ in range(ceiling):

        // Select the instance from our unlabeled copy that scores highest.
        raw_instance = select_instance(X_training=labeled, X_uncertainty=unlabeled_uncertainty_copy)
        instance = np.expand_dims(raw_instance, axis=1)

        // Find our record"s index in both the original unlabeled and our uncertainty copy.
        instance_index_original = np.where(np.all(unlabeled == raw_instance, axis=1))[0][0]
        instance_index_copy = np.where(np.all(unlabeled_uncertainty_copy[:, :-1] == instance.T, axis=1))[0][0]

        // Add our instance we"ve considered for labeling to our labeled set. Although we don"t
        // know it"s label, we want further iterations to consider the newly-added instance so
        // that we don"t query the same instance redundantly.
        labeled = np.concatenate((labeled, instance.T), axis=0)

        // Remove our instance from the unlabeled set and append it to our list of records to label.
        unlabeled_uncertainty_copy = np.delete(unlabeled_uncertainty_copy, instance_index_copy, axis=0)
        instance_index_ranking.append(instance_index_original)

    // Return numpy array, not a list.
    return np.array(instance_index_ranking)

After Change


    unlabeled_uncertainty = np.concatenate((unlabeled, expanded_uncertainty_scores), axis=1)

    // Define our null row, which will be filtered during the select_instance call.
    null_row = np.ones(shape=(unlabeled_uncertainty.shape[1],)) * np.nan

    // Define our record container and the maximum number of records to sample.
    instance_index_ranking = []
    ceiling = np.minimum(unlabeled.shape[0], n_instances)

    for _ in range(ceiling):

        // Receive the instance and corresponding index from our unlabeled copy that scores highest.
        instance_index, instance = select_instance(
            X_training=labeled, X_uncertainty=unlabeled_uncertainty
        )

        // Prepare our most informative instance for concatenation.
        expanded_instance = np.expand_dims(instance, axis=0)

        // Add our instance we"ve considered for labeling to our labeled set. Although we don"t
        // know it"s label, we want further iterations to consider the newly-added instance so
        // that we don"t query the same instance redundantly.
        labeled = np.concatenate((labeled, expanded_instance), axis=0)

        // We "remove" our instance from the unlabeled set by setting that row to an array
        // of np.nan and filtering within select_instance.
        unlabeled_uncertainty[instance_index] = null_row

        // Finally, append our instance"s index to the bottom of our ranking.
        instance_index_ranking.append(instance_index)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: modAL-python/modAL
Commit Name: f8df6021a1343d511d4c9b4c108ec5b683ce5487
Time: 2018-08-14
Author: dannyofig@gmail.com
File Name: modAL/batch.py
Class Name:
Method Name: ranked_batch


Project Name: utkuozbulak/pytorch-cnn-visualizations
Commit Name: 3df2eaf74d8f2299ca05e3e98cab5bf89dafc249
Time: 2017-10-24
Author: utku.ozbulak@gmail.com
File Name: cnn_visualisation.py
Class Name:
Method Name: preprocess_image


Project Name: chainer/chainercv
Commit Name: 08aeb66bf5f5e91dff7f76768c70d591b17a4117
Time: 2017-05-28
Author: Hakuyume@users.noreply.github.com
File Name: chainercv/links/model/ssd/train_transformer.py
Class Name: TrainTransformer
Method Name: __call__