<s> import lasagne <EOL> import lasagne . layers as L <EOL> import lasagne . nonlinearities as NL <EOL> import lasagne . init as LI <EOL> from rllab . core . lasagne_powered import LasagnePowered <EOL> from rllab . core . lasagne_layers import batch_norm <EOL> from rllab . core . serializable import Serializable <EOL> from rllab . misc import ext <EOL> from rllab . policies . base import Policy <EOL> class DeterministicMLPPolicy ( Policy , LasagnePowered , Serializable ) : <EOL> def __init__ ( <EOL> self , <EOL> env_spec , <EOL> hidden_sizes = ( <NUM_LIT:32> , <NUM_LIT:32> ) , <EOL> hidden_nonlinearity = NL . rectify , <EOL> hidden_W_init = LI . HeUniform ( ) , <EOL> hidden_b_init = LI . Constant ( <NUM_LIT:0.> ) , <EOL> output_nonlinearity = NL . tanh , <EOL> output_W_init = LI . Uniform ( - <NUM_LIT> , <NUM_LIT> ) , <EOL> output_b_init = LI . Uniform ( - <NUM_LIT> , <NUM_LIT> ) , <EOL> bn = False ) : <EOL> Serializable . quick_init ( self , locals ( ) ) <EOL> l_obs = L . InputLayer ( shape = ( None , env_spec . observation_space . flat_dim ) ) <EOL> l_hidden = l_obs <EOL> if bn : <EOL> l_hidden = batch_norm ( l_hidden ) <EOL> for idx , size in enumerate ( hidden_sizes ) : <EOL> l_hidden = L . DenseLayer ( <EOL> l_hidden , <EOL> num_units = size , <EOL> W = hidden_W_init , <EOL> b = hidden_b_init , <EOL> nonlinearity = hidden_nonlinearity , <EOL> name = "<STR_LIT>" % idx <EOL> ) <EOL> if bn : <EOL> l_hidden = batch_norm ( l_hidden ) <EOL> l_output = L . DenseLayer ( <EOL> l_hidden , <EOL> num_units = env_spec . action_space . flat_dim , <EOL> W = output_W_init , <EOL> b = output_b_init , <EOL> nonlinearity = output_nonlinearity , <EOL> name = "<STR_LIT>" <EOL> ) <EOL> action_var = L . get_output ( l_output , deterministic = True ) <EOL> self . _output_layer = l_output <EOL> self . _f_actions = ext . compile_function ( [ l_obs . input_var ] , action_var ) <EOL> super ( DeterministicMLPPolicy , self ) . __init__ ( env_spec ) <EOL> LasagnePowered . __init__ ( self , [ l_output ] ) <EOL> def get_action ( self , observation ) : <EOL> action = self . _f_actions ( [ observation ] ) [ <NUM_LIT:0> ] <EOL> return action , dict ( ) <EOL> def get_actions ( self , observations ) : <EOL> return self . _f_actions ( observations ) , dict ( ) <EOL> def get_action_sym ( self , obs_var ) : <EOL> return L . get_output ( self . _output_layer , obs_var ) </s>
