-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathstrap.py
More file actions
33 lines (26 loc) · 668 Bytes
/
strap.py
File metadata and controls
33 lines (26 loc) · 668 Bytes
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
from mlp import MLP
import numpy
import theano
from theano import tensor as T
if __name__ == "__main__":
rng = numpy.random.RandomState(1234)
index = T.lscalar()
x = T.matrix('x')
y = T.ivector('y')
classifier = MLP (
rng=rng,
input=x,
n_in=2,
n_hidden=5,
n_out=2
)
data = numpy.asarray([[4., 3, 2], [1, 2, 1]])
forward = theano.function(
inputs=[index],
outputs=classifier.pred(x),
givens={
x: data[index:index+2]
}
)
cost = -T.log(classifier.pred[y] + 1e-8).mean() + 0.00 * classifier.L1 + 0.00 * classifier.L2_sqr
print forward(0)