#NEWLINE# def _get_cost( self , y_enc , output , w1 , w2 ) : #NEWLINE# #INDENT# 'Compute cost function.\n\n        y_enc : array, shape = (n_labels, n_samples)\n            one-hot encoded class labels.\n        output : array, shape = [n_output_units, n_samples]\n            Activation of the output layer (feedforward)\n        w1 : array, shape = [n_hidden_units, n_features]\n            Weight matrix for input layer -> hidden layer.\n        w2 : array, shape = [n_output_units, n_hidden_units]\n            Weight matrix for hidden layer -> output layer.\n\n        Returns\n        ---------\n        cost : float\n            Regularized cost.\n\n        ' #NEWLINE# term1 = ( ( - y_enc ) * np . log ( output ) ) #NEWLINE# term2 = ( ( 1.0 - y_enc ) * np . log ( ( 1.0 - output ) ) ) #NEWLINE# cost = np . sum ( ( term1 - L1_term ) ) #NEWLINE# L1_term = self . _L1_reg ( self . l1 , w1 , w2 ) #NEWLINE# L2_term = self . _L2_reg ( self . l2 , w1 , w2 ) #NEWLINE# cost = ( ( cost + L1_term ) + L2_term ) #NEWLINE# return cost