[−][src]Struct auto_diff::op::loss::BCEWithLogitsLoss
This loss combines a Sigmoid layer and the BCELoss in one single class. This version is more numerically stable than using a plain Sigmoid followed by a BCELoss as, by combining the operations into one layer, we take advantage of the log-sum-exp trick for numerical stability.
-y log (1/(1 + exp(-x))) - (1-y) log(1 - 1/(1 + exp(-x)))
Prediction comes first, label comes second.
Methods
impl BCEWithLogitsLoss
[src]
pub fn new() -> BCEWithLogitsLoss
[src]
Trait Implementations
impl OpTrait for BCEWithLogitsLoss
[src]
fn get_name(&self) -> String
[src]
fn apply(&mut self, input: &[&Tensor], output: &[&Tensor])
[src]
The first is the prediction, the second input is the label
fn grad(
&self,
input: &[&Tensor],
output_grad: &[&Tensor],
input_grad: &[&Tensor]
)
[src]
&self,
input: &[&Tensor],
output_grad: &[&Tensor],
input_grad: &[&Tensor]
)
Given the forward input value and backward output_grad, Update weight gradient. return backward input gradeint.
fn get_values(&self) -> Vec<&Tensor>
[src]
access weight values
fn set_values(&self, v: &[Tensor])
[src]
fn get_grads(&self) -> Vec<&Tensor>
[src]
access gradient values
Auto Trait Implementations
impl RefUnwindSafe for BCEWithLogitsLoss
impl Send for BCEWithLogitsLoss
impl Sync for BCEWithLogitsLoss
impl Unpin for BCEWithLogitsLoss
impl UnwindSafe for BCEWithLogitsLoss
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,