def __init__(self, name, x, y, n_in, n_out):
self.x= x
self.name = name
# weight matrix W (n_in, n_out)
self.W = theano.shared(
value=np.zeros((n_in, n_out), dtype=theano.config.floatX),
name='W',
borrow=True)
# bias vector b (n_out, )
self.b = theano.shared(
value=np.zeros((n_out,), dtype=theano.config.floatX),
name='b',
borrow=True)
# p(y|x, w, b)
self.p_y_given_x = T.nnet.softmax(T.dot(x, self.W) + self.b)
self.y_pred = T.argmax(self.p_y_given_x, axis=1)
self.negative_log_likelihood = -T.mean(T.log(self.p_y_given_x)[T.arange(y.shape[0]), y])
self.errors = T.mean(T.neq(self.y_pred, y))
# params
self.params = [self.W, self.b]
评论列表
文章目录