<s> from theano import tensor as T <EOL> from . import NeuralNetwork <EOL> from deepy . utils import dim_to_var , RegressionCost <EOL> class NeuralRegressor ( NeuralNetwork ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , input_dim , target_tensor = <NUM_LIT:2> , clip_value = None , input_tensor = None ) : <EOL> self . target_tensor = dim_to_var ( target_tensor , "<STR_LIT:k>" ) if type ( target_tensor ) == int else target_tensor <EOL> self . clip_value = clip_value <EOL> super ( NeuralRegressor , self ) . __init__ ( input_dim , input_tensor = input_tensor ) <EOL> def setup_variables ( self ) : <EOL> super ( NeuralRegressor , self ) . setup_variables ( ) <EOL> self . k = self . target_tensor <EOL> self . target_variables . append ( self . k ) <EOL> def _cost_func ( self , y ) : <EOL> if self . clip_value : <EOL> y = T . clip ( y , - self . clip_value , self . clip_value ) <EOL> return RegressionCost ( y , self . k ) . get ( ) <EOL> @ property <EOL> def cost ( self ) : <EOL> return self . _cost_func ( self . output ) <EOL> @ property <EOL> def test_cost ( self ) : <EOL> return self . _cost_func ( self . test_output ) </s>
