1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import numpy as np

class Encoder(object):
    def __init__(self,class_number,start_with=0):
        self._start_with = 0
        self._n_class = class_number
    
    def one_hot_encode(self,x):
        y = np.zeros(self._n_class,dtype=float)
        y[x - self._start_with] = 1
        return y
    
    def label(self,X):
        return np.argmax(X) + self._start_with

 

 

 

arrow
arrow
    文章標籤
    python
    全站熱搜
    創作者介紹
    創作者 Lung-Yu,Tsai 的頭像
    Lung-Yu,Tsai

    Lung-Yu,Tsai 的部落格

    Lung-Yu,Tsai 發表在 痞客邦 留言(0) 人氣()