<s> """<STR_LIT>""" <EOL> import unittest <EOL> import numpy <EOL> import six . moves . cPickle as pickle <EOL> from theano . compat import DictMixin , OrderedDict <EOL> import theano <EOL> import theano . tensor as T <EOL> floatX = '<STR_LIT>' <EOL> def test_pickle_unpickle_with_reoptimization ( ) : <EOL> mode = theano . config . mode <EOL> if mode in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> mode = "<STR_LIT>" <EOL> x1 = T . fmatrix ( '<STR_LIT>' ) <EOL> x2 = T . fmatrix ( '<STR_LIT>' ) <EOL> x3 = theano . shared ( numpy . ones ( ( <NUM_LIT:10> , <NUM_LIT:10> ) , dtype = floatX ) ) <EOL> x4 = theano . shared ( numpy . ones ( ( <NUM_LIT:10> , <NUM_LIT:10> ) , dtype = floatX ) ) <EOL> y = T . sum ( T . sum ( T . sum ( x1 ** <NUM_LIT:2> + x2 ) + x3 ) + x4 ) <EOL> updates = OrderedDict ( ) <EOL> updates [ x3 ] = x3 + <NUM_LIT:1> <EOL> updates [ x4 ] = x4 + <NUM_LIT:1> <EOL> f = theano . function ( [ x1 , x2 ] , y , updates = updates , mode = mode ) <EOL> string_pkl = pickle . dumps ( f , - <NUM_LIT:1> ) <EOL> in1 = numpy . ones ( ( <NUM_LIT:10> , <NUM_LIT:10> ) , dtype = floatX ) <EOL> in2 = numpy . ones ( ( <NUM_LIT:10> , <NUM_LIT:10> ) , dtype = floatX ) <EOL> default = theano . config . reoptimize_unpickled_function <EOL> try : <EOL> theano . config . reoptimize_unpickled_function = True <EOL> f_ = pickle . loads ( string_pkl ) <EOL> assert f ( in1 , in2 ) == f_ ( in1 , in2 ) <EOL> finally : <EOL> theano . config . reoptimize_unpickled_function = default <EOL> def test_pickle_unpickle_without_reoptimization ( ) : <EOL> mode = theano . config . mode <EOL> if mode in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> mode = "<STR_LIT>" <EOL> x1 = T . fmatrix ( '<STR_LIT>' ) <EOL> x2 = T . fmatrix ( '<STR_LIT>' ) <EOL> x3 = theano . shared ( numpy . ones ( ( <NUM_LIT:10> , <NUM_LIT:10> ) , dtype = floatX ) ) <EOL> x4 = theano . shared ( numpy . ones ( ( <NUM_LIT:10> , <NUM_LIT:10> ) , dtype = floatX ) ) <EOL> y = T . sum ( T . sum ( T . sum ( x1 ** <NUM_LIT:2> + x2 ) + x3 ) + x4 ) <EOL> updates = OrderedDict ( ) <EOL> updates [ x3 ] = x3 + <NUM_LIT:1> <EOL> updates [ x4 ] = x4 + <NUM_LIT:1> <EOL> f = theano . function ( [ x1 , x2 ] , y , updates = updates , mode = mode ) <EOL> string_pkl = pickle . dumps ( f , - <NUM_LIT:1> ) <EOL> in1 = numpy . ones ( ( <NUM_LIT:10> , <NUM_LIT:10> ) , dtype = floatX ) <EOL> in2 = numpy . ones ( ( <NUM_LIT:10> , <NUM_LIT:10> ) , dtype = floatX ) <EOL> default = theano . config . reoptimize_unpickled_function <EOL> try : <EOL> theano . config . reoptimize_unpickled_function = False <EOL> f_ = pickle . loads ( string_pkl ) <EOL> assert f ( in1 , in2 ) == f_ ( in1 , in2 ) <EOL> finally : <EOL> theano . config . reoptimize_unpickled_function = default <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_pickle_unpickle_with_reoptimization ( ) <EOL> test_pickle_unpickle_without_reoptimization ( ) </s>
