softmax.py 文件源码

python
阅读 45 收藏 0 点赞 0 评论 0

项目:lmkit 作者: jiangnanhugo 项目源码 文件源码
def __init__(self,n_input,n_output,x):
        self.n_input=n_input
        self.n_output=n_output

        self.x=x.reshape([-1,x.shape[-1]])

        init_W=np.asarray(np.random.uniform(low=-np.sqrt(1./n_input),
                                             high=np.sqrt(1./n_input),
                                             size=(n_input,n_output)),dtype=theano.config.floatX)
        init_b=np.zeros((n_output),dtype=theano.config.floatX)

        self.W=theano.shared(value=init_W,name='output_W',borrow=True)
        self.b=theano.shared(value=init_b,name='output_b',borrow=True)

        self.params=[self.W,self.b]

        self.activation=T.nnet.softmax(T.dot(self.x,self.W)+self.b)
        self.predict=T.argmax(self.activation,axis=-1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号