|
1 |
| -""" |
2 |
| -Unit tests for blocks |
3 |
| -""" |
4 |
| - |
5 |
| -from pylearn2.models.autoencoder import Autoencoder |
6 |
| -from pylearn2.blocks import Block, StackedBlocks |
7 |
| - |
8 |
| - |
9 |
| -def test_stackedblocks_with_params(): |
10 |
| - """ |
11 |
| - Test StackedBlocks when all layers have trainable params |
12 |
| - """ |
13 |
| - |
14 |
| - aes = [Autoencoder(100, 50, 'tanh', 'tanh'), |
15 |
| - Autoencoder(50, 10, 'tanh', 'tanh')] |
16 |
| - sb = StackedBlocks(aes) |
17 |
| - _params = set([p for l in sb._layers for p in l._params]) |
18 |
| - |
19 |
| - assert sb._params == _params |
20 |
| - |
21 |
| - |
22 |
| -def test_stackedblocks_without_params(): |
23 |
| - """ |
24 |
| - Test StackedBlocks when not all layers have trainable params |
25 |
| - """ |
26 |
| - |
27 |
| - sb = StackedBlocks([Block(), Block()]) |
28 |
| - |
29 |
| - assert sb._params is None |
| 1 | +""" |
| 2 | +Unit tests for blocks |
| 3 | +""" |
| 4 | + |
| 5 | +from pylearn2.models.autoencoder import Autoencoder |
| 6 | +from pylearn2.blocks import Block, StackedBlocks |
| 7 | + |
| 8 | + |
| 9 | +def test_stackedblocks_with_params(): |
| 10 | + """ |
| 11 | + Test StackedBlocks when all layers have trainable params |
| 12 | + """ |
| 13 | + |
| 14 | + aes = [Autoencoder(100, 50, 'tanh', 'tanh'), |
| 15 | + Autoencoder(50, 10, 'tanh', 'tanh')] |
| 16 | + sb = StackedBlocks(aes) |
| 17 | + _params = set([p for l in sb._layers for p in l._params]) |
| 18 | + |
| 19 | + assert sb._params == _params |
| 20 | + |
| 21 | + |
| 22 | +def test_stackedblocks_without_params(): |
| 23 | + """ |
| 24 | + Test StackedBlocks when not all layers have trainable params |
| 25 | + """ |
| 26 | + |
| 27 | + sb = StackedBlocks([Block(), Block()]) |
| 28 | + |
| 29 | + assert sb._params is None |
0 commit comments