Skip to main content

Parameter

Trait Parameter 

Source
pub trait Parameter: ParameterValue {
    // Required methods
    fn is_require_grad(&self) -> bool;
    fn set_require_grad(self, require_grad: bool) -> Self;
    fn device(&self) -> Device;
    fn shape(&self) -> Shape;
    fn load_to_device(self, device: &Device) -> Self;
}
Expand description

A tensor-backed ParameterValue with autodiff, device and loading capabilities.

General module-owned values can implement ParameterValue without pretending to require gradients, reside on a device or have a tensor shape.

Required Methods§

Source

fn is_require_grad(&self) -> bool

Fetch the gradient requirement.

Source

fn set_require_grad(self, require_grad: bool) -> Self

Set the gradient requirement.

Float tensors without autodiff remain unchanged. Param::set_require_grad stores the configured training state so it can be applied when entering training mode.

Source

fn device(&self) -> Device

Fetch the device.

Source

fn shape(&self) -> Shape

Fetch the shape of the parameter.

Source

fn load_to_device(self, device: &Device) -> Self

Moves the parameter to the target device if it is not already on it, applying any kind-specific preparation required for the loading lifecycle (e.g. detach).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<const D: usize> Parameter for Tensor<D, Bool>

Source§

impl<const D: usize> Parameter for Tensor<D, Float>

Source§

impl<const D: usize> Parameter for Tensor<D, Int>