pub struct Sampler { /* private fields */ }Expand description
Sampler for generating predictions from model outputs
Implementations§
Source§impl Sampler
impl Sampler
Sourcepub fn new(config: SamplingConfig) -> Self
pub fn new(config: SamplingConfig) -> Self
Create a new sampler with given configuration
Sourcepub fn with_custom_fn(
config: SamplingConfig,
custom_fn: CustomSamplingFn,
) -> Self
pub fn with_custom_fn( config: SamplingConfig, custom_fn: CustomSamplingFn, ) -> Self
Create a sampler with a custom sampling function
Sourcepub fn set_custom_fn(&mut self, custom_fn: CustomSamplingFn)
pub fn set_custom_fn(&mut self, custom_fn: CustomSamplingFn)
Set custom sampling function
Sourcepub fn sample_batch(
&mut self,
logits: &Array2<f32>,
) -> InferenceResult<Array1<f32>>
pub fn sample_batch( &mut self, logits: &Array2<f32>, ) -> InferenceResult<Array1<f32>>
Sample multiple values from a batch of logits
Sourcepub fn config(&self) -> &SamplingConfig
pub fn config(&self) -> &SamplingConfig
Get the current configuration
Auto Trait Implementations§
impl Freeze for Sampler
impl !RefUnwindSafe for Sampler
impl Send for Sampler
impl Sync for Sampler
impl Unpin for Sampler
impl !UnwindSafe for Sampler
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