def log_1_plus_exp(mat, target=None, exact=False):
 if (not target):
  target = mat
 if exact:
  err_code = _cudamat.apply_log_1_plus_exp_exact(mat.p_mat, target.p_mat)
 else:
  err_code = _cudamat.apply_log_1_plus_exp(mat.p_mat, target.p_mat)
 if err_code:
  raise generate_exception(err_code)
 return target

def log_1_plus_exp ( mat , target = None , exact = False ) : if ( not target ) : target = mat if exact : err_code = _cudamat . apply_log_1_plus_exp_exact ( mat . p_mat , target . p_mat ) else : err_code = _cudamat . apply_log_1_plus_exp ( mat . p_mat , target . p_mat ) if err_code : raise generate_exception ( err_code ) return target
apply log(1+exp(x)) to each element of the matrix mat .