Mercurial > pylearn
comparison algorithms/logistic_regression.py @ 495:7560817a07e8
nnet_ops => nnet
author | Joseph Turian <turian@gmail.com> |
---|---|
date | Tue, 28 Oct 2008 12:09:39 -0400 |
parents | 180d125dc7e2 |
children | a272f4cbf004 |
comparison
equal
deleted
inserted
replaced
494:02a331ba833b | 495:7560817a07e8 |
---|---|
1 import theano | 1 import theano |
2 from theano import tensor as T | 2 from theano import tensor as T |
3 from theano.tensor import nnet_ops | 3 from theano.tensor import nnet |
4 from theano.compile import module | 4 from theano.compile import module |
5 from theano import printing, pprint | 5 from theano import printing, pprint |
6 from theano import compile | 6 from theano import compile |
7 | 7 |
8 import numpy as N | 8 import numpy as N |
28 self.b = b if b is not None else module.Member(T.dvector()) | 28 self.b = b if b is not None else module.Member(T.dvector()) |
29 self.lr = lr if lr is not None else module.Member(T.dscalar()) | 29 self.lr = lr if lr is not None else module.Member(T.dscalar()) |
30 | 30 |
31 self.params = [p for p in [self.w, self.b] if p.owner is None] | 31 self.params = [p for p in [self.w, self.b] if p.owner is None] |
32 | 32 |
33 xent, y = nnet_ops.crossentropy_softmax_1hot( | 33 xent, y = nnet.crossentropy_softmax_1hot( |
34 T.dot(self.x, self.w) + self.b, self.targ) | 34 T.dot(self.x, self.w) + self.b, self.targ) |
35 sum_xent = T.sum(xent) | 35 sum_xent = T.sum(xent) |
36 | 36 |
37 self.y = y | 37 self.y = y |
38 self.sum_xent = sum_xent | 38 self.sum_xent = sum_xent |
68 self.b = b if b is not None else module.Member(T.dvector()) | 68 self.b = b if b is not None else module.Member(T.dvector()) |
69 self.lr = lr if lr is not None else module.Member(T.dscalar()) | 69 self.lr = lr if lr is not None else module.Member(T.dscalar()) |
70 | 70 |
71 self.params = [p for p in [self.w, self.b] if p.owner is None] | 71 self.params = [p for p in [self.w, self.b] if p.owner is None] |
72 | 72 |
73 y = nnet_ops.sigmoid(T.dot(self.x, self.w)) | 73 y = nnet.sigmoid(T.dot(self.x, self.w)) |
74 xent = -self.targ * T.log(y) - (1.0 - self.targ) * T.log(1.0 - y) | 74 xent = -self.targ * T.log(y) - (1.0 - self.targ) * T.log(1.0 - y) |
75 sum_xent = T.sum(xent) | 75 sum_xent = T.sum(xent) |
76 | 76 |
77 self.y = y | 77 self.y = y |
78 self.xent = xent | 78 self.xent = xent |