pub struct BinaryCrossEntropyLoss<B>where
B: Backend,{
pub weights: Option<Tensor<B, 1>>,
pub smoothing: Option<f32>,
pub logits: bool,
}
Expand description
Calculate the binary cross entropy loss from the input logits and the targets.
Should be created using BinaryCrossEntropyLossConfig
Fields§
§weights: Option<Tensor<B, 1>>
Weights for cross-entropy.
smoothing: Option<f32>
Label smoothing alpha.
logits: bool
Treat the inputs as logits
Implementations§
Source§impl<B> BinaryCrossEntropyLoss<B>where
B: Backend,
impl<B> BinaryCrossEntropyLoss<B>where
B: Backend,
Trait Implementations§
Source§impl<B> AutodiffModule<B> for BinaryCrossEntropyLoss<B>
impl<B> AutodiffModule<B> for BinaryCrossEntropyLoss<B>
Source§type InnerModule = BinaryCrossEntropyLoss<<B as AutodiffBackend>::InnerBackend>
type InnerModule = BinaryCrossEntropyLoss<<B as AutodiffBackend>::InnerBackend>
Inner module without auto-differentiation.
Source§fn valid(&self) -> <BinaryCrossEntropyLoss<B> as AutodiffModule<B>>::InnerModule
fn valid(&self) -> <BinaryCrossEntropyLoss<B> as AutodiffModule<B>>::InnerModule
Get the same module, but on the inner backend without auto-differentiation.
Source§impl<B> Clone for BinaryCrossEntropyLoss<B>where
B: Backend,
impl<B> Clone for BinaryCrossEntropyLoss<B>where
B: Backend,
Source§fn clone(&self) -> BinaryCrossEntropyLoss<B>
fn clone(&self) -> BinaryCrossEntropyLoss<B>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<B> Debug for BinaryCrossEntropyLoss<B>
impl<B> Debug for BinaryCrossEntropyLoss<B>
Source§impl<B> Display for BinaryCrossEntropyLoss<B>where
B: Backend,
impl<B> Display for BinaryCrossEntropyLoss<B>where
B: Backend,
Source§impl<B> Module<B> for BinaryCrossEntropyLoss<B>where
B: Backend,
impl<B> Module<B> for BinaryCrossEntropyLoss<B>where
B: Backend,
Source§type Record = BinaryCrossEntropyLossRecord<B>
type Record = BinaryCrossEntropyLossRecord<B>
Type to save and load the module.
Source§fn load_record(
self,
record: <BinaryCrossEntropyLoss<B> as Module<B>>::Record,
) -> BinaryCrossEntropyLoss<B>
fn load_record( self, record: <BinaryCrossEntropyLoss<B> as Module<B>>::Record, ) -> BinaryCrossEntropyLoss<B>
Load the module state from a record.
Source§fn into_record(self) -> <BinaryCrossEntropyLoss<B> as Module<B>>::Record
fn into_record(self) -> <BinaryCrossEntropyLoss<B> as Module<B>>::Record
Convert the module into a record containing the state.
Source§fn num_params(&self) -> usize
fn num_params(&self) -> usize
Get the number of parameters the module has, including all of its sub-modules.
Source§fn visit<Visitor>(&self, visitor: &mut Visitor)where
Visitor: ModuleVisitor<B>,
fn visit<Visitor>(&self, visitor: &mut Visitor)where
Visitor: ModuleVisitor<B>,
Visit each tensor parameter in the module with a visitor.
Source§fn map<Mapper>(self, mapper: &mut Mapper) -> BinaryCrossEntropyLoss<B>where
Mapper: ModuleMapper<B>,
fn map<Mapper>(self, mapper: &mut Mapper) -> BinaryCrossEntropyLoss<B>where
Mapper: ModuleMapper<B>,
Map each tensor parameter in the module with a mapper.
Source§fn collect_devices(
&self,
devices: Vec<<B as Backend>::Device>,
) -> Vec<<B as Backend>::Device>
fn collect_devices( &self, devices: Vec<<B as Backend>::Device>, ) -> Vec<<B as Backend>::Device>
Return all the devices found in the underneath module tree added to the given vector
without duplicates.
Source§fn to_device(self, device: &<B as Backend>::Device) -> BinaryCrossEntropyLoss<B>
fn to_device(self, device: &<B as Backend>::Device) -> BinaryCrossEntropyLoss<B>
Move the module and all of its sub-modules to the given device. Read more
Source§fn fork(self, device: &<B as Backend>::Device) -> BinaryCrossEntropyLoss<B>
fn fork(self, device: &<B as Backend>::Device) -> BinaryCrossEntropyLoss<B>
Fork the module and all of its sub-modules to the given device. Read more
Source§fn devices(&self) -> Vec<<B as Backend>::Device>
fn devices(&self) -> Vec<<B as Backend>::Device>
Return all the devices found in the underneath module tree without duplicates.
Source§fn save_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
) -> Result<(), RecorderError>
fn save_file<FR, PB>( self, file_path: PB, recorder: &FR, ) -> Result<(), RecorderError>
Save the module to a file using the provided file recorder. Read more
Source§fn load_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
device: &<B as Backend>::Device,
) -> Result<Self, RecorderError>
fn load_file<FR, PB>( self, file_path: PB, recorder: &FR, device: &<B as Backend>::Device, ) -> Result<Self, RecorderError>
Load the module from a file using the provided file recorder. Read more
Source§fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
Quantize the weights of the module.
Source§impl<B> ModuleDisplay for BinaryCrossEntropyLoss<B>where
B: Backend,
impl<B> ModuleDisplay for BinaryCrossEntropyLoss<B>where
B: Backend,
Source§fn custom_settings(&self) -> Option<DisplaySettings>
fn custom_settings(&self) -> Option<DisplaySettings>
Custom display settings for the module. Read more
Auto Trait Implementations§
impl<B> Freeze for BinaryCrossEntropyLoss<B>where
<B as Backend>::FloatTensorPrimitive: Freeze,
<B as Backend>::QuantizedTensorPrimitive: Freeze,
impl<B> RefUnwindSafe for BinaryCrossEntropyLoss<B>where
<B as Backend>::FloatTensorPrimitive: RefUnwindSafe,
<B as Backend>::QuantizedTensorPrimitive: RefUnwindSafe,
impl<B> Send for BinaryCrossEntropyLoss<B>
impl<B> Sync for BinaryCrossEntropyLoss<B>
impl<B> Unpin for BinaryCrossEntropyLoss<B>
impl<B> UnwindSafe for BinaryCrossEntropyLoss<B>where
<B as Backend>::FloatTensorPrimitive: UnwindSafe,
<B as Backend>::QuantizedTensorPrimitive: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more