Mercurial > pylearn
comparison pylearn/shared/layers/tests/test_sigmoidal_layer.py @ 1447:fbe470217937
Use .get_value() and .set_value() of shared instead of the .value property
author | Pascal Lamblin <lamblinp@iro.umontreal.ca> |
---|---|
date | Wed, 16 Mar 2011 20:20:02 -0400 |
parents | 912be602c3ac |
children |
comparison
equal
deleted
inserted
replaced
1446:6e50d209b5f1 | 1447:fbe470217937 |
---|---|
22 cost = out.nll(y).sum() | 22 cost = out.nll(y).sum() |
23 params = out.params+layer.params | 23 params = out.params+layer.params |
24 updates = [(p, p - numpy.asarray(0.01, dtype=dtype)*gp) for p,gp in zip(params, tensor.grad(cost, params)) ] | 24 updates = [(p, p - numpy.asarray(0.01, dtype=dtype)*gp) for p,gp in zip(params, tensor.grad(cost, params)) ] |
25 f = pfunc([x, y], cost, updates=updates) | 25 f = pfunc([x, y], cost, updates=updates) |
26 | 26 |
27 w0 = layer.w.value.copy() | 27 w0 = layer.w.get_value(borrow=False) |
28 b0 = layer.b.value.copy() | 28 b0 = layer.b.get_value(borrow=False) |
29 | 29 |
30 xval = numpy.asarray(rng.rand(bsize, n_in), dtype=dtype) | 30 xval = numpy.asarray(rng.rand(bsize, n_in), dtype=dtype) |
31 yval = numpy.asarray(rng.randint(0,2,bsize), dtype='int64') | 31 yval = numpy.asarray(rng.randint(0,2,bsize), dtype='int64') |
32 f0 = f(xval, yval) | 32 f0 = f(xval, yval) |
33 for i in xrange(n_iter): | 33 for i in xrange(n_iter): |
34 fN = f(xval, yval) | 34 fN = f(xval, yval) |
35 print i, 'rval', fN | 35 print i, 'rval', fN |
36 | 36 |
37 assert f0 > 6 | 37 assert f0 > 6 |
38 assert fN < 2 | 38 assert fN < 2 |
39 | 39 |
40 assert numpy.all(w0 != layer.w.value) | 40 assert numpy.all(w0 != layer.w.get_value(borrow=True)) |
41 assert numpy.all(b0 != layer.b.value) | 41 assert numpy.all(b0 != layer.b.get_value(borrow=True)) |