pub struct TrainableContinuousTokenizer { /* private fields */ }Expand description
Trainable continuous tokenizer with gradient descent
Implementations§
Source§impl TrainableContinuousTokenizer
impl TrainableContinuousTokenizer
Sourcepub fn new(input_dim: usize, embed_dim: usize) -> CandleResult<Self>
pub fn new(input_dim: usize, embed_dim: usize) -> CandleResult<Self>
Create a new trainable continuous tokenizer
Sourcepub fn train_batch(
&self,
signals: &[Array1<f32>],
optimizer: &mut AdamW,
) -> TokenizerResult<f32>
pub fn train_batch( &self, signals: &[Array1<f32>], optimizer: &mut AdamW, ) -> TokenizerResult<f32>
Train on a batch of signals
Sourcepub fn train(
&self,
training_data: &[Array1<f32>],
config: &TrainingConfig,
) -> TokenizerResult<Vec<f32>>
pub fn train( &self, training_data: &[Array1<f32>], config: &TrainingConfig, ) -> TokenizerResult<Vec<f32>>
Train on a dataset
Sourcepub fn encode(&self, signal: &Array1<f32>) -> TokenizerResult<Array1<f32>>
pub fn encode(&self, signal: &Array1<f32>) -> TokenizerResult<Array1<f32>>
Encode a signal (inference)
Sourcepub fn decode(&self, embeddings: &Array1<f32>) -> TokenizerResult<Array1<f32>>
pub fn decode(&self, embeddings: &Array1<f32>) -> TokenizerResult<Array1<f32>>
Decode embeddings (inference)
Sourcepub fn get_encoder_weights(&self) -> TokenizerResult<Array2<f32>>
pub fn get_encoder_weights(&self) -> TokenizerResult<Array2<f32>>
Get encoder weights as Array2
Sourcepub fn get_decoder_weights(&self) -> TokenizerResult<Array2<f32>>
pub fn get_decoder_weights(&self) -> TokenizerResult<Array2<f32>>
Get decoder weights as Array2
Sourcepub fn evaluate(
&self,
test_data: &[Array1<f32>],
) -> TokenizerResult<ReconstructionMetrics>
pub fn evaluate( &self, test_data: &[Array1<f32>], ) -> TokenizerResult<ReconstructionMetrics>
Evaluate reconstruction quality on test data
Sourcepub fn save_checkpoint<P: AsRef<Path>>(
&self,
path: P,
version: &str,
training_config: Option<TrainingConfig>,
metrics: Option<ReconstructionMetrics>,
) -> TokenizerResult<()>
pub fn save_checkpoint<P: AsRef<Path>>( &self, path: P, version: &str, training_config: Option<TrainingConfig>, metrics: Option<ReconstructionMetrics>, ) -> TokenizerResult<()>
Save model to checkpoint
Sourcepub fn load_checkpoint<P: AsRef<Path>>(path: P) -> TokenizerResult<Self>
pub fn load_checkpoint<P: AsRef<Path>>(path: P) -> TokenizerResult<Self>
Load model from checkpoint
Sourcepub fn peek_checkpoint<P: AsRef<Path>>(
path: P,
) -> TokenizerResult<ModelMetadata>
pub fn peek_checkpoint<P: AsRef<Path>>( path: P, ) -> TokenizerResult<ModelMetadata>
Get metadata from a checkpoint file without loading the full model
Auto Trait Implementations§
impl Freeze for TrainableContinuousTokenizer
impl !RefUnwindSafe for TrainableContinuousTokenizer
impl Send for TrainableContinuousTokenizer
impl Sync for TrainableContinuousTokenizer
impl Unpin for TrainableContinuousTokenizer
impl !UnwindSafe for TrainableContinuousTokenizer
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> 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 more