Automatic Differentiation
 
Loading...
Searching...
No Matches
binary_log_loss.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_BINARY_LOG_LOSS_HPP
2#define STAN_MATH_FWD_FUN_BINARY_LOG_LOSS_HPP
3
7
8namespace stan {
9namespace math {
10
11template <typename T>
12inline fvar<T> binary_log_loss(int y, const fvar<T>& y_hat) {
13 if (y) {
14 return fvar<T>(binary_log_loss(y, y_hat.val_), -y_hat.d_ / y_hat.val_);
15 } else {
16 return fvar<T>(binary_log_loss(y, y_hat.val_),
17 y_hat.d_ / (1.0 - y_hat.val_));
18 }
19}
20} // namespace math
21} // namespace stan
22#endif
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 ...
Scalar val_
The value of this variable.
Definition fvar.hpp:49
Scalar d_
The tangent (derivative) of this variable.
Definition fvar.hpp:61
This template class represents scalars used in forward-mode automatic differentiation,...
Definition fvar.hpp:40