Struct tch::TrainableCModule

source ·
pub struct TrainableCModule { /* private fields */ }
Expand description

The trainable version of a jit PyTorch module.

These modules can be created via the TorchScript python api.

Implementations§

source§

impl TrainableCModule

source

pub fn load<T: AsRef<Path>>( module_path: T, path: Path<'_> ) -> Result<Self, TchError>

Loads a PyTorch saved JIT module from a file.

This function also adds the tensors from the JIT module to the VarStore path passed as argument so that the module can be trained.

source

pub fn load_data<T: Read>( data: &mut T, path: Path<'_> ) -> Result<Self, TchError>

Loads a PyTorch saved JIT model from a read instance.

This function also adds the tensors from the JIT module to the VarStore path passed as argument so that the module can be trained.

source

pub fn save<T: AsRef<Path>>(&self, module_path: T) -> Result<(), TchError>

source

pub fn f_set_train(&mut self) -> Result<(), TchError>

Switches the module to training mode.

source

pub fn set_train(&mut self)

Switches the module to training mode.

source

pub fn f_set_eval(&mut self) -> Result<(), TchError>

Switches the module to evaluation mode.

source

pub fn set_eval(&mut self)

Switches the module to evaluation mode.

source

pub fn forward_ts<T: Borrow<Tensor>>( &self, ts: &[T] ) -> Result<Tensor, TchError>

Performs the forward pass for a model on some specified tensor inputs.

source

pub fn forward_is<T: Borrow<IValue>>( &self, ts: &[T] ) -> Result<IValue, TchError>

Performs the forward pass for a model on some specified ivalue inputs.

source

pub fn method_ts<T: Borrow<Tensor>>( &self, method_name: &str, ts: &[T] ) -> Result<Tensor, TchError>

Runs a specified entry point for a model on some given tensor inputs.

source

pub fn method_is<T: Borrow<IValue>>( &self, method_name: &str, ts: &[T] ) -> Result<IValue, TchError>

Runs a specified entry point for a model on some given ivalue inputs.

Trait Implementations§

source§

impl Debug for TrainableCModule

source§

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

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

impl ModuleT for TrainableCModule

source§

fn forward_t(&self, xs: &Tensor, _train: bool) -> Tensor

source§

fn batch_accuracy_for_logits( &self, xs: &Tensor, ys: &Tensor, d: Device, batch_size: i64 ) -> f64

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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