<commit_before># -*- coding: utf-8 -*-
"""
Created on Thu Oct 15 16:05:52 2015

@author: matsumi
"""

import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits


def onehot(k, num_classes=10):
    num_examples = len(k)
    t_onehot = np.zeros((num_examples, num_classes))
    t_onehot[np.arange(num_examples), k] = 1
    return t_onehot
<commit_msg>onehot関数のshapeを転置する<commit_after># -*- coding: utf-8 -*-
"""
Created on Thu Oct 15 16:05:52 2015

@author: matsumi
"""

import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits


def onehot(k, num_classes=10):
    num_examples = len(k)
    t_onehot = np.zeros((num_examples, num_classes))
    t_onehot[np.arange(num_examples), k] = 1
    return t_onehot

t = np.random.choice(10, 200)
T = onehot(t).T
print onehot(t).shape
print T.shape

{'fraction_non_alphanumeric': 0.1239766081871345, 'fraction_numerical': 0.04327485380116959, 'mean_word_length': 4.219512195121951, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2828849', 'n_tokens_mistral': 367, 'n_tokens_neox': 328, 'n_words': 83}