def elemwise_kl(Y, Y_hat):
 assert hasattr(Y_hat, 'owner')
 owner = Y_hat.owner
 assert (owner is not None)
 op = owner.op
 if (not hasattr(op, 'scalar_op')):
  raise ValueError(((('Expected Y_hat to be generated by an Elemwise op, got ' + str(op)) + ' of type ') + str(type(op))))
 assert isinstance(op.scalar_op, T.nnet.sigm.ScalarSigmoid)
 for Yv in get_debug_values(Y):
  if (not ((Yv.min() >= 0.0) and (Yv.max() <= 1.0))):
   raise ValueError(('Expected Y to be between 0 and 1. Either Y' + '< 0 or Y > 1 was found in the input.'))
 (z,) = owner.inputs
 term_1 = (Y * T.nnet.softplus((- z)))
 term_2 = ((1 - Y) * T.nnet.softplus(z))
 total = (term_1 + term_2)
 return total

def elemwise_kl ( Y , Y_hat ) : assert hasattr ( Y_hat , 'owner' ) owner = Y_hat . owner assert ( owner is not None ) op = owner . op if ( not hasattr ( op , 'scalar_op' ) ) : raise ValueError ( ( ( ( 'Expected Y_hat to be generated by an Elemwise op, got ' + str ( op ) ) + ' of type ' ) + str ( type ( op ) ) ) ) assert isinstance ( op . scalar_op , T . nnet . sigm . ScalarSigmoid ) for Yv in get_debug_values ( Y ) : if ( not ( ( Yv . min ( ) >= 0.0 ) and ( Yv . max ( ) <= 1.0 ) ) ) : raise ValueError ( ( 'Expected Y to be between 0 and 1. Either Y' + '< 0 or Y > 1 was found in the input.' ) ) ( z , ) = owner . inputs term_1 = ( Y * T . nnet . softplus ( ( - z ) ) ) term_2 = ( ( 1 - Y ) * T . nnet . softplus ( z ) ) total = ( term_1 + term_2 ) return total
warning: this function expects a sigmoid nonlinearity in the output layer .