<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> from pylearn2 . models import Model <EOL> from pylearn2 . utils import sharedX <EOL> def test_get_set_vector ( ) : <EOL> """<STR_LIT>""" <EOL> rng = np . random . RandomState ( [ <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:8> ] ) <EOL> class DummyModel ( Model ) : <EOL> """<STR_LIT>""" <EOL> _params = [ sharedX ( rng . randn ( <NUM_LIT:5> ) ) , sharedX ( rng . randn ( <NUM_LIT:5> , <NUM_LIT:3> ) ) , <EOL> sharedX ( rng . randn ( <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:4> ) ) ] <EOL> model = DummyModel ( ) <EOL> vector = model . get_param_vector ( ) <EOL> model . set_param_vector ( <NUM_LIT:0.> * vector ) <EOL> assert np . allclose ( <NUM_LIT:0.> * vector , model . get_param_vector ( ) ) <EOL> model . set_param_vector ( vector ) <EOL> assert np . allclose ( model . get_param_vector ( ) , vector ) <EOL> def test_tag ( ) : <EOL> """<STR_LIT>""" <EOL> class DummyModel ( Model ) : <EOL> """<STR_LIT>""" <EOL> x = DummyModel ( ) <EOL> x . tag [ '<STR_LIT:foo>' ] [ '<STR_LIT:bar>' ] = <NUM_LIT:5> <EOL> assert len ( x . tag . keys ( ) ) == <NUM_LIT:1> <EOL> assert len ( x . tag [ '<STR_LIT:foo>' ] . keys ( ) ) == <NUM_LIT:1> <EOL> assert x . tag [ '<STR_LIT:foo>' ] [ '<STR_LIT:bar>' ] == <NUM_LIT:5> <EOL> assert '<STR_LIT:bar>' not in x . tag <EOL> x . tag [ '<STR_LIT:bar>' ] [ '<STR_LIT>' ] = <NUM_LIT:3> <EOL> assert '<STR_LIT:bar>' in x . tag <EOL> assert '<STR_LIT>' in x . tag [ '<STR_LIT:bar>' ] <EOL> assert len ( x . tag . keys ( ) ) == <NUM_LIT:2> </s>
