Skip to main content

BasicBlock

Struct BasicBlock 

Source
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: usize

Reduction 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>

Source

pub fn debug_print(&self)

Debug Print.

Source

pub fn forward(&self, input: Tensor<B, 4>) -> Tensor<B, 4>

Forward Pass.

§Arguments
  • input: [batch, in_planes, in_height=out_height*stride, in_width=out_width*stride].
§Returns

A [batch, out_planes=planes*expansion_factor, out_height, out_width] tensor.

Source

pub fn with_drop_path_prob(self, drop_path_prob: f64) -> Self

Set the drop path probability.

Source

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>

Source§

type InnerModule = BasicBlock<<B as AutodiffBackend>::InnerBackend>

Inner module without auto-differentiation.
Source§

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>

Source§

fn in_planes(&self) -> usize

The size of the in channels dimension.
Source§

fn out_planes(&self) -> usize

The size of the out channels dimension.
Source§

fn dilation(&self) -> usize

Dilation rate for conv layers.
Source§

fn first_dilation(&self) -> Option<usize>

Optional first-dilation override.
Source§

fn reduce_first(&self) -> usize

Control factor for first_planes()
Source§

fn first_planes(&self) -> usize

First conv/norm layer output channels. Read more
Source§

fn stride(&self) -> usize

The stride of convolution. Read more
Source§

fn effective_first_dilation(&self) -> usize

Resolved first dilation.
Source§

fn output_resolution(&self, input_resolution: [usize; 2]) -> [usize; 2]

Get the output resolution for a given input resolution. Read more
Source§

impl<B: Backend> Clone for BasicBlock<B>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Debug + Backend> Debug for BasicBlock<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B: Backend> Display for BasicBlock<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B: Backend> From<BasicBlock<B>> for ResidualBlock<B>

Source§

fn from(block: BasicBlock<B>) -> Self

Converts to this type from the input type.
Source§

impl<B: Backend> Module<B> for BasicBlock<B>

Source§

type Record = BasicBlockRecord<B>

Type to save and load the module.
Source§

fn load_record(self, record: Self::Record) -> Self

Load the module state from a record.
Source§

fn into_record(self) -> Self::Record

Convert the module into a record containing the state.
Source§

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)

Visit each tensor parameter in the module with a visitor.
Source§

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>

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

Move the module and all of its sub-modules to the given device. Read more
Source§

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>

Return all the devices found in the underneath module tree without duplicates.
Source§

fn no_grad(self) -> Self

Each tensor in the module tree will not require grad. Read more
Source§

fn save_file<FR, PB>( self, file_path: PB, recorder: &FR, ) -> Result<(), RecorderError>
where FR: FileRecorder<B>, PB: Into<PathBuf>,

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>
where FR: FileRecorder<B>, PB: Into<PathBuf>,

Load the module from a file using the provided file recorder. Read more
Source§

fn quantize_weights(self, quantizer: &mut Quantizer) -> Self

Quantize the weights of the module.
Source§

impl<B: Backend> ModuleDisplay for BasicBlock<B>

Source§

fn format(&self, passed_settings: DisplaySettings) -> String

Formats the module with provided display settings. Read more
Source§

fn custom_settings(&self) -> Option<DisplaySettings>

Custom display settings for the module. Read more
Source§

fn custom_content(&self, _content: Content) -> Option<Content>

Custom attributes for the module. Read more
Source§

impl<B: Backend> ModuleDisplayDefault for BasicBlock<B>

Source§

fn content(&self, content: Content) -> Option<Content>

Attributes of the module used for display purposes. Read more
Source§

fn num_params(&self) -> usize

Gets the number of the parameters of the module.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<B, M> ModuleSnapshot<B> for M
where B: Backend, M: Module<B>,

Source§

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>>, ) -> ApplyResult
where 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,

Saves tensor snapshots into a ModuleStore. Read more
Source§

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more