<s> import numpy as np <EOL> from . import backend as K <EOL> def binary_accuracy ( y_true , y_pred ) : <EOL> return K . mean ( K . equal ( y_true , K . round ( y_pred ) ) ) <EOL> def categorical_accuracy ( y_true , y_pred ) : <EOL> return K . mean ( K . equal ( K . argmax ( y_true , axis = - <NUM_LIT:1> ) , <EOL> K . argmax ( y_pred , axis = - <NUM_LIT:1> ) ) ) <EOL> def sparse_categorical_accuracy ( y_true , y_pred ) : <EOL> return K . mean ( K . equal ( K . max ( y_true , axis = - <NUM_LIT:1> ) , <EOL> K . cast ( K . argmax ( y_pred , axis = - <NUM_LIT:1> ) , K . floatx ( ) ) ) ) <EOL> def mean_squared_error ( y_true , y_pred ) : <EOL> return K . mean ( K . square ( y_pred - y_true ) ) <EOL> def mean_absolute_error ( y_true , y_pred ) : <EOL> return K . mean ( K . abs ( y_pred - y_true ) ) <EOL> def mean_absolute_percentage_error ( y_true , y_pred ) : <EOL> diff = K . abs ( ( y_true - y_pred ) / K . clip ( K . abs ( y_true ) , K . epsilon ( ) , np . inf ) ) <EOL> return <NUM_LIT> * K . mean ( diff ) <EOL> def mean_squared_logarithmic_error ( y_true , y_pred ) : <EOL> first_log = K . log ( K . clip ( y_pred , K . epsilon ( ) , np . inf ) + <NUM_LIT:1.> ) <EOL> second_log = K . log ( K . clip ( y_true , K . epsilon ( ) , np . inf ) + <NUM_LIT:1.> ) <EOL> return K . mean ( K . square ( first_log - second_log ) ) <EOL> def squared_hinge ( y_true , y_pred ) : <EOL> return K . mean ( K . square ( K . maximum ( <NUM_LIT:1.> - y_true * y_pred , <NUM_LIT:0.> ) ) ) <EOL> def hinge ( y_true , y_pred ) : <EOL> return K . mean ( K . maximum ( <NUM_LIT:1.> - y_true * y_pred , <NUM_LIT:0.> ) ) <EOL> def categorical_crossentropy ( y_true , y_pred ) : <EOL> '''<STR_LIT>''' <EOL> return K . mean ( K . categorical_crossentropy ( y_pred , y_true ) ) <EOL> def sparse_categorical_crossentropy ( y_true , y_pred ) : <EOL> '''<STR_LIT>''' <EOL> return K . mean ( K . sparse_categorical_crossentropy ( y_pred , y_true ) ) <EOL> def binary_crossentropy ( y_true , y_pred ) : <EOL> return K . mean ( K . binary_crossentropy ( y_pred , y_true ) ) <EOL> def poisson ( y_true , y_pred ) : <EOL> return K . mean ( y_pred - y_true * K . log ( y_pred + K . epsilon ( ) ) ) <EOL> def cosine_proximity ( y_true , y_pred ) : <EOL> y_true = K . l2_normalize ( y_true , axis = - <NUM_LIT:1> ) <EOL> y_pred = K . l2_normalize ( y_pred , axis = - <NUM_LIT:1> ) <EOL> return - K . mean ( y_true * y_pred ) <EOL> mse = MSE = mean_squared_error <EOL> mae = MAE = mean_absolute_error <EOL> mape = MAPE = mean_absolute_percentage_error <EOL> msle = MSLE = mean_squared_logarithmic_error <EOL> cosine = cosine_proximity <EOL> from . utils . generic_utils import get_from_module <EOL> def get ( identifier ) : <EOL> return get_from_module ( identifier , globals ( ) , '<STR_LIT>' ) </s>
