pub struct BasicBlock<B: Backend> {
pub reduce_first: usize,
pub downsample: Option<ResNetDownsample<B>>,
pub cna1: CNA2d<B>,
pub cna2: CNA2d<B>,
pub drop_block: Option<DropBlock2d>,
pub drop_path: Option<DropPath>,
}Expand description
Basic Block for ResNet.
Implements BasicBlockMeta.
Fields§
§reduce_first: usizeReduction factor.
downsample: Option<ResNetDownsample<B>>Optional DownSample layer; for the residual connection.
cna1: CNA2d<B>First Conv/Norm/Act Block.
cna2: CNA2d<B>Second Conv/Norm/Act Block.
drop_block: Option<DropBlock2d>Optional DropBlock layer.
drop_path: Option<DropPath>Optional DropPath layer.
Implementations§
Source§impl<B: Backend> BasicBlock<B>
impl<B: Backend> BasicBlock<B>
Sourcepub fn debug_print(&self)
pub fn debug_print(&self)
Debug Print.
Sourcepub fn with_drop_path_prob(self, drop_path_prob: f64) -> Self
pub fn with_drop_path_prob(self, drop_path_prob: f64) -> Self
Set the drop path probability.
Sourcepub fn with_drop_block(self, drop_block: Option<DropBlockOptions>) -> Self
pub fn with_drop_block(self, drop_block: Option<DropBlockOptions>) -> Self
Set the drop block behavior.
Trait Implementations§
Source§impl<B> AutodiffModule<B> for BasicBlock<B>
impl<B> AutodiffModule<B> for BasicBlock<B>
Source§type InnerModule = BasicBlock<<B as AutodiffBackend>::InnerBackend>
type InnerModule = BasicBlock<<B as AutodiffBackend>::InnerBackend>
Inner module without auto-differentiation.
Source§fn valid(&self) -> Self::InnerModule
fn valid(&self) -> Self::InnerModule
Get the same module, but on the inner backend without auto-differentiation.
Source§impl<B: Backend> BasicBlockMeta for BasicBlock<B>
impl<B: Backend> BasicBlockMeta for BasicBlock<B>
Source§fn out_planes(&self) -> usize
fn out_planes(&self) -> usize
The size of the out channels dimension.
Source§fn first_dilation(&self) -> Option<usize>
fn first_dilation(&self) -> Option<usize>
Optional first-dilation override.
Source§fn reduce_first(&self) -> usize
fn reduce_first(&self) -> usize
Control factor for
first_planes()Source§fn first_planes(&self) -> usize
fn first_planes(&self) -> usize
First conv/norm layer output channels. Read more
Source§fn effective_first_dilation(&self) -> usize
fn effective_first_dilation(&self) -> usize
Resolved first dilation.
Source§impl<B: Backend> Clone for BasicBlock<B>
impl<B: Backend> Clone for BasicBlock<B>
Source§impl<B: Backend> Display for BasicBlock<B>
impl<B: Backend> Display for BasicBlock<B>
Source§impl<B: Backend> From<BasicBlock<B>> for ResidualBlock<B>
impl<B: Backend> From<BasicBlock<B>> for ResidualBlock<B>
Source§fn from(block: BasicBlock<B>) -> Self
fn from(block: BasicBlock<B>) -> Self
Converts to this type from the input type.
Source§impl<B: Backend> Module<B> for BasicBlock<B>
impl<B: Backend> Module<B> for BasicBlock<B>
Source§type Record = BasicBlockRecord<B>
type Record = BasicBlockRecord<B>
Type to save and load the module.
Source§fn load_record(self, record: Self::Record) -> Self
fn load_record(self, record: Self::Record) -> Self
Load the module state from a record.
Source§fn into_record(self) -> Self::Record
fn into_record(self) -> Self::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: ModuleVisitor<B>>(&self, visitor: &mut Visitor)
fn visit<Visitor: ModuleVisitor<B>>(&self, visitor: &mut Visitor)
Visit each tensor parameter in the module with a visitor.
Source§fn map<Mapper: ModuleMapper<B>>(self, mapper: &mut Mapper) -> Self
fn map<Mapper: ModuleMapper<B>>(self, mapper: &mut Mapper) -> Self
Map each tensor parameter in the module with a mapper.
Source§fn collect_devices(&self, devices: Devices<B>) -> Devices<B>
fn collect_devices(&self, devices: Devices<B>) -> Devices<B>
Return all the devices found in the underneath module tree added to the given vector
without duplicates.
Source§fn to_device(self, device: &B::Device) -> Self
fn to_device(self, device: &B::Device) -> Self
Move the module and all of its sub-modules to the given device. Read more
Source§fn fork(self, device: &B::Device) -> Self
fn fork(self, device: &B::Device) -> Self
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: Backend> ModuleDisplay for BasicBlock<B>
impl<B: Backend> ModuleDisplay for BasicBlock<B>
Source§fn format(&self, passed_settings: DisplaySettings) -> String
fn format(&self, passed_settings: DisplaySettings) -> String
Formats the module with provided display settings. Read more
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 BasicBlock<B>
impl<B> !RefUnwindSafe for BasicBlock<B>
impl<B> !Sync for BasicBlock<B>
impl<B> !UnwindSafe for BasicBlock<B>
impl<B> Send for BasicBlock<B>
impl<B> Unpin for BasicBlock<B>where
<B as Backend>::FloatTensorPrimitive: Unpin,
<B as Backend>::QuantizedTensorPrimitive: Unpin,
<B as Backend>::Device: Unpin,
impl<B> UnsafeUnpin for BasicBlock<B>where
<B as Backend>::FloatTensorPrimitive: UnsafeUnpin,
<B as Backend>::QuantizedTensorPrimitive: UnsafeUnpin,
<B as Backend>::Device: UnsafeUnpin,
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<B, M> ModuleSnapshot<B> for M
impl<B, M> ModuleSnapshot<B> for M
Source§fn collect(
&self,
filter: Option<PathFilter>,
adapter: Option<Box<dyn ModuleAdapter>>,
) -> Vec<TensorSnapshot>
fn collect( &self, filter: Option<PathFilter>, adapter: Option<Box<dyn ModuleAdapter>>, ) -> Vec<TensorSnapshot>
Collects tensor snapshots for inspection without copying data. Read more
Source§fn apply(
&mut self,
snapshots: Vec<TensorSnapshot>,
filter: Option<PathFilter>,
adapter: Option<Box<dyn ModuleAdapter>>,
) -> ApplyResultwhere
Self: Sized,
fn apply(
&mut self,
snapshots: Vec<TensorSnapshot>,
filter: Option<PathFilter>,
adapter: Option<Box<dyn ModuleAdapter>>,
) -> ApplyResultwhere
Self: Sized,
Applies tensor snapshots to the module. Read more
Source§fn save_into<P>(&self, store: &mut P) -> Result<(), <P as ModuleStore>::Error>where
P: ModuleStore,
fn save_into<P>(&self, store: &mut P) -> Result<(), <P as ModuleStore>::Error>where
P: ModuleStore,
Saves tensor snapshots into a
ModuleStore. Read moreSource§fn load_from<P>(
&mut self,
store: &mut P,
) -> Result<ApplyResult, <P as ModuleStore>::Error>where
P: ModuleStore,
fn load_from<P>(
&mut self,
store: &mut P,
) -> Result<ApplyResult, <P as ModuleStore>::Error>where
P: ModuleStore,
Loads tensor data from a
ModuleStore. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.