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

def planes(num_planes):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

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: TheAlgorithms/Python
Commit Name: e8aa81297a6291a7d0994d71605f07d654aae17c
Time: 2019-11-19
Author: fmokadem@umich.edu
File Name: digital_image_processing/filters/gaussian_filter.py
Class Name:
Method Name: gaussian_filter


Project Name: BindsNET/bindsnet
Commit Name: 5895434c8e31e7a446c70aeea5529a59d8054f50
Time: 2018-07-26
Author: djsaunde@umass.edu
File Name: bindsnet/evaluation/__init__.py
Class Name:
Method Name: update_ngram_scores