1#ifndef STAN_MATH_REV_FUN_BINARY_LOG_LOSS_HPP
2#define STAN_MATH_REV_FUN_BINARY_LOG_LOSS_HPP
49 y_hat.adj() += vi.adj() / (1.0 - y_hat.val());
53 y_hat.adj() -= vi.adj() / y_hat.val();
61template <
typename Mat, require_eigen_t<Mat>* =
nullptr>
65 -(-y_hat.val().array()).log1p(), [y_hat](
auto& vi)
mutable {
66 y_hat.adj().array() += vi.adj().array() / (1.0 - y_hat.val().array());
70 -y_hat.val().array().log(), [y_hat](
auto& vi)
mutable {
71 y_hat.adj().array() -= vi.adj().array() / y_hat.val().array();
80template <
typename StdVec,
typename Mat, require_eigen_t<Mat>* =
nullptr,
81 require_st_
integral<StdVec>* =
nullptr>
86 .
select((-y_hat.val().array()).log1p(), y_hat.val().array().log());
91 .select((1.0 - y_hat.val().array()), -y_hat.val().array());
select_< as_operation_cl_t< T_condition >, as_operation_cl_t< T_then >, as_operation_cl_t< T_else > > select(T_condition &&condition, T_then &&then, T_else &&els)
Selection operation on kernel generator expressions.
T as_array_or_scalar(T &&v)
Returns specified input value.
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
arena_t< T > to_arena(const T &a)
Converts given argument into a type that either has any dynamic allocation on AD stack or schedules i...
fvar< T > log1p(const fvar< T > &x)
fvar< T > binary_log_loss(int y, const fvar< T > &y_hat)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...