forked from r00tman/kfac-theano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logreg.py
34 lines (26 loc) · 889 Bytes
/
logreg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import numpy.random as nprng
import theano
import theano.tensor as T
from theano_utils import floatX
class LogReg:
def __init__(self, inp, shape, act=T.nnet.sigmoid):
self.shape = shape
print(shape)
self.W = theano.shared(
value=floatX(nprng.randn(shape[0], shape[1])*np.sqrt(2/shape[1])),
# value=floatX(nprng.randn(shape[0], shape[1])*np.sqrt(2/(shape[1] + shape[0]))),
name='W',
borrow=True
)
# self.b = theano.shared(
# value=floatX(nprng.randn(shape[0])*np.sqrt(2/shape[0])),
# name='b',
# borrow=True
# )
# self.s = T.dot(self.W, inp.T).T + self.b
self.s = T.dot(self.W, inp.T).T
self.a = act(self.s)
# self.params = [self.W, self.b]
self.params = [self.W]
self.inp = inp