def objective(layers, loss_function, target, aggregate=aggregate, deterministic=False, l1=0, l2=0, get_output_kw=None):
 if (get_output_kw is None):
  get_output_kw = {}
 output_layer = layers[(-1)]
 network_output = get_output(output_layer, deterministic=deterministic, **get_output_kw)
 loss = aggregate(loss_function(network_output, target))
 if l1:
  loss += (regularization.regularize_layer_params(layers.values(), regularization.l1) * l1)
 if l2:
  loss += (regularization.regularize_layer_params(layers.values(), regularization.l2) * l2)
 return loss

def objective ( layers , loss_function , target , aggregate = aggregate , deterministic = False , l1 = 0 , l2 = 0 , get_output_kw = None ) : if ( get_output_kw is None ) : get_output_kw = { } output_layer = layers [ ( - 1 ) ] network_output = get_output ( output_layer , deterministic = deterministic , ** get_output_kw ) loss = aggregate ( loss_function ( network_output , target ) ) if l1 : loss += ( regularization . regularize_layer_params ( layers . values ( ) , regularization . l1 ) * l1 ) if l2 : loss += ( regularization . regularize_layer_params ( layers . values ( ) , regularization . l2 ) * l2 ) return loss
default implementation of the neuralnet objective .