<s> import pytest <EOL> import numpy as np <EOL> from numpy . testing import assert_allclose <EOL> from keras . layers import wrappers , Input <EOL> from keras . layers import core , convolutional <EOL> from keras . models import Sequential , Model , model_from_json <EOL> def test_TimeDistributed ( ) : <EOL> model = Sequential ( ) <EOL> model . add ( wrappers . TimeDistributed ( core . Dense ( <NUM_LIT:2> ) , input_shape = ( <NUM_LIT:3> , <NUM_LIT:4> ) ) ) <EOL> model . add ( core . Activation ( '<STR_LIT:relu>' ) ) <EOL> model . compile ( optimizer = '<STR_LIT>' , loss = '<STR_LIT>' ) <EOL> model . fit ( np . random . random ( ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:4> ) ) , np . random . random ( ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:2> ) ) , nb_epoch = <NUM_LIT:1> , batch_size = <NUM_LIT:10> ) <EOL> model . get_config ( ) <EOL> test_input = np . random . random ( ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> ) ) <EOL> test_output = model . predict ( test_input ) <EOL> weights = model . layers [ <NUM_LIT:0> ] . get_weights ( ) <EOL> reference = Sequential ( ) <EOL> reference . add ( core . TimeDistributedDense ( <NUM_LIT:2> , input_shape = ( <NUM_LIT:3> , <NUM_LIT:4> ) , weights = weights ) ) <EOL> reference . add ( core . Activation ( '<STR_LIT:relu>' ) ) <EOL> reference . compile ( optimizer = '<STR_LIT>' , loss = '<STR_LIT>' ) <EOL> reference_output = reference . predict ( test_input ) <EOL> assert_allclose ( test_output , reference_output , atol = <NUM_LIT> ) <EOL> reference = Sequential ( ) <EOL> reference . add ( core . TimeDistributedDense ( <NUM_LIT:2> , batch_input_shape = ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> ) , weights = weights ) ) <EOL> reference . add ( core . Activation ( '<STR_LIT:relu>' ) ) <EOL> reference . compile ( optimizer = '<STR_LIT>' , loss = '<STR_LIT>' ) <EOL> reference_output = reference . predict ( test_input ) <EOL> assert_allclose ( test_output , reference_output , atol = <NUM_LIT> ) <EOL> model = Sequential ( ) <EOL> model . add ( wrappers . TimeDistributed ( convolutional . Convolution2D ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:2> , border_mode = '<STR_LIT>' ) , input_shape = ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:4> ) ) ) <EOL> model . add ( core . Activation ( '<STR_LIT:relu>' ) ) <EOL> model . compile ( optimizer = '<STR_LIT>' , loss = '<STR_LIT>' ) <EOL> model . train_on_batch ( np . random . random ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:4> ) ) , np . random . random ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:4> , <NUM_LIT:4> ) ) ) <EOL> model = model_from_json ( model . to_json ( ) ) <EOL> model . summary ( ) <EOL> model = Sequential ( ) <EOL> model . add ( wrappers . TimeDistributed ( core . Dense ( <NUM_LIT:2> ) , input_shape = ( <NUM_LIT:3> , <NUM_LIT:4> ) ) ) <EOL> model . add ( wrappers . TimeDistributed ( core . Dense ( <NUM_LIT:3> ) ) ) <EOL> model . add ( core . Activation ( '<STR_LIT:relu>' ) ) <EOL> model . compile ( optimizer = '<STR_LIT>' , loss = '<STR_LIT>' ) <EOL> model . fit ( np . random . random ( ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:4> ) ) , np . random . random ( ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:3> ) ) , nb_epoch = <NUM_LIT:1> , batch_size = <NUM_LIT:10> ) <EOL> model = Sequential ( ) <EOL> model . add ( core . Dense ( <NUM_LIT:3> , input_dim = <NUM_LIT:2> ) ) <EOL> outer_model = Sequential ( ) <EOL> outer_model . add ( wrappers . TimeDistributed ( model , input_shape = ( <NUM_LIT:3> , <NUM_LIT:2> ) ) ) <EOL> outer_model . compile ( optimizer = '<STR_LIT>' , loss = '<STR_LIT>' ) <EOL> outer_model . fit ( np . random . random ( ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:2> ) ) , np . random . random ( ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:3> ) ) , nb_epoch = <NUM_LIT:1> , batch_size = <NUM_LIT:10> ) <EOL> x = Input ( shape = ( <NUM_LIT:3> , <NUM_LIT:2> ) ) <EOL> y = wrappers . TimeDistributed ( model ) ( x ) <EOL> outer_model = Model ( x , y ) <EOL> outer_model . compile ( optimizer = '<STR_LIT>' , loss = '<STR_LIT>' ) <EOL> outer_model . fit ( np . random . random ( ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:2> ) ) , np . random . random ( ( <NUM_LIT:10> , <NUM_LIT:3> , <NUM_LIT:3> ) ) , nb_epoch = <NUM_LIT:1> , batch_size = <NUM_LIT:10> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> pytest . main ( [ __file__ ] ) </s>
