3f09a5c3431a0b259bd7310d8d3c9737ff514fa7,features.py,,make_onehot,#Any#Any#,27

Before Change



def make_onehot(feature, planes):
    onehot_features = np.zeros(feature.shape + (planes,), dtype=np.uint8)
    for i in range(planes - 1):
        onehot_features[:, :, i] = (feature == i+1)
    onehot_features[:, :, planes-1] = (feature >= planes)
    return onehot_features

def planes(num_planes):

After Change


def make_onehot(feature, planes):
    onehot_features = np.zeros(feature.shape + (planes,), dtype=np.uint8)
    capped = np.minimum(feature, planes)
    onehot_index_offsets = np.arange(0, product(onehot_features.shape), planes) + capped.ravel()
    // A 0 is encoded as [0,0,0,0], not [1,0,0,0], so we"ll
    // filter out any offsets that are a multiple of $planes
    // A 1 is encoded as [1,0,0,0], not [0,1,0,0], so subtract 1 from offsets
    nonzero_elements = (capped != 0).ravel()
    nonzero_index_offsets = onehot_index_offsets[nonzero_elements] - 1
    onehot_features.ravel()[nonzero_index_offsets] = 1
    return onehot_features
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: brilee/MuGo
Commit Name: 3f09a5c3431a0b259bd7310d8d3c9737ff514fa7
Time: 2016-10-24
Author: brian.kihoon.lee@gmail.com
File Name: features.py
Class Name:
Method Name: make_onehot


Project Name: uqfoundation/mystic
Commit Name: 5aa02316482e48940e1b79423b713337b4911fb7
Time: 2015-10-13
Author: mmckerns@968178ea-60bd-409e-af13-df8a517b6005
File Name: mystic/svmtools.py
Class Name:
Method Name: KernelMatrix


Project Name: yzhao062/pyod
Commit Name: 24d96c7ec2d80322ceb7a084199b891c9ebf88b9
Time: 2019-03-12
Author: yalmardeny@tssg,org
File Name: pyod/models/sod.py
Class Name: SOD
Method Name: _snn