comparison sandbox/simple_autoassociator/graph.py @ 393:36baeb7125a4

Made sandbox directory
author Joseph Turian <turian@gmail.com>
date Tue, 08 Jul 2008 18:46:26 -0400
parents simple_autoassociator/graph.py@e2cb8d489908
children 8cc11ac97087
comparison
equal deleted inserted replaced
392:e2cb8d489908 393:36baeb7125a4
1 """
2 Theano graph for a simple autoassociator.
3 @todo: Make nearly everything private.
4 """
5
6 from pylearn.nnet_ops import sigmoid, binary_crossentropy
7 from theano import tensor as t
8 from theano.tensor import dot
9 x = t.dvector()
10 w1 = t.dmatrix()
11 b1 = t.dvector()
12 w2 = t.dmatrix()
13 b2 = t.dvector()
14 h = sigmoid(dot(x, w1) + b1)
15 y = sigmoid(dot(h, w2) + b2)
16
17 loss_unsummed = binary_crossentropy(y, x)
18 loss = t.sum(loss_unsummed)
19
20 (gw1, gb1, gw2, gb2, gy) = t.grad(loss, [w1, b1, w2, b2, y])
21
22 import theano.compile
23
24 inputs = [x, w1, b1, w2, b2]
25 outputs = [y, h, loss, loss_unsummed, gw1, gb1, gw2, gb2, gy]
26 trainfn = theano.compile.function(inputs, outputs)