Struct relearn::torch::initializers::TensorBuilder
source · [−]pub struct TensorBuilder<'a> { /* private fields */ }
Expand description
Builder for initializing a new tensor.
Implementations
sourceimpl<'a> TensorBuilder<'a>
impl<'a> TensorBuilder<'a>
pub const fn new(initializer: &'a Initializer, shape: &'a [usize]) -> Self
sourcepub const fn gain(self, gain: f64) -> Self
pub const fn gain(self, gain: f64) -> Self
Set the gain (scaling factor) on the initialized values.
Can be used to compensate for the scaling effect of activation functions.
See PyTorch’s calculate_gain
function for more information.
sourcepub const fn fan_in(self, fan_in: usize) -> Self
pub const fn fan_in(self, fan_in: usize) -> Self
Override the fan_in
value (number of input features) calculated from shape
.
This can be useful when multiple tensors are initialized separately but act together in
a layer to implement a mapping from a collectively larger number of input features.
For example, a weights tensor and a bias tensors might be initialized with a fan_in
value
of weights_input_dim + 1
.
sourcepub const fn fan_out(self, fan_out: usize) -> Self
pub const fn fan_out(self, fan_out: usize) -> Self
Override the fan_out
value (number of output features) calculated from shape
.
This can be useful when multiple tensors are initialized separately but their outputs features are concatenated together in a layer.
sourcepub const fn requires_grad(self, requires_grad: bool) -> Self
pub const fn requires_grad(self, requires_grad: bool) -> Self
Set whether the tensor requires gradient tracking. Defaults to true.
Trait Implementations
sourceimpl<'a> Clone for TensorBuilder<'a>
impl<'a> Clone for TensorBuilder<'a>
sourcefn clone(&self) -> TensorBuilder<'a>
fn clone(&self) -> TensorBuilder<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for TensorBuilder<'a>
impl<'a> Debug for TensorBuilder<'a>
sourceimpl<'a> PartialEq<TensorBuilder<'a>> for TensorBuilder<'a>
impl<'a> PartialEq<TensorBuilder<'a>> for TensorBuilder<'a>
sourcefn eq(&self, other: &TensorBuilder<'a>) -> bool
fn eq(&self, other: &TensorBuilder<'a>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &TensorBuilder<'a>) -> bool
fn ne(&self, other: &TensorBuilder<'a>) -> bool
This method tests for !=
.
impl<'a> Copy for TensorBuilder<'a>
impl<'a> StructuralPartialEq for TensorBuilder<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for TensorBuilder<'a>
impl<'a> Send for TensorBuilder<'a>
impl<'a> Sync for TensorBuilder<'a>
impl<'a> Unpin for TensorBuilder<'a>
impl<'a> UnwindSafe for TensorBuilder<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more