[][src]Struct sparrow::scanner::buffer_loader::BufferLoader

pub struct BufferLoader {
    pub size: usize,
    pub base_model: Tree,
    pub base_model_sig: String,
    pub current_version: usize,
    pub new_buffer: Arc<RwLock<Option<(usize, Vec<(LabeledData<u8, i8>, (f32, usize))>, Tree, String)>>>,
    pub sample_mode: SampleMode,
    pub ess: f32,
    // some fields omitted
}

Double-buffered sample set. It consists of two buffers stores in memory. One of the buffer is used for providing examples to the boosting algorithm, meanwhile the other would receive new examples from the sampler module. Once the other buffer is filled, the functions of the two buffers switch so that the sample set used for training would be updated periodically.

It might take several scans over the sample set before the new sample set is ready. Thus it is very likely that the examples in the sample set would be accessed multiple times.

Fields

size: usizebase_model: Treebase_model_sig: Stringcurrent_version: usizenew_buffer: Arc<RwLock<Option<(usize, Vec<(LabeledData<u8, i8>, (f32, usize))>, Tree, String)>>>sample_mode: SampleModeess: f32

Methods

impl BufferLoader[src]

pub fn new(
    size: usize,
    batch_size: usize,
    sample_mode: SampleMode,
    sleep_duration: usize,
    min_ess: f32,
    exp_name: String
) -> BufferLoader
[src]

Create a new BufferLoader.

size: the size of sample set. The total size of the two buffers would be 2x of size. batch_size: the number of examples that feeds to the boosting algorithm at a time.

If init_block is set to true, this function would block until the first sample set is created (i.e. enough examples is received from the sampler). Alternatively, one can explicitly call the load function to create the first sample set before start training the boosting algorithm.

pub fn get_num_batches(&self) -> usize[src]

Return the number of batches (i.e. the number of function calls to get_next_batch) before exhausting the current sample set.

pub fn get_next_batch(
    &mut self,
    allow_switch: bool
) -> (&[(LabeledData<u8, i8>, (f32, f32, usize, usize))], bool)
[src]

Read next batch of examples.

allow_switch: If set to true, the alternate buffer would be checked if it was ready. If it was, the loader will switched to the alternate buffer for reading the next batch of examples.

pub fn get_next_batch_and_update(
    &mut self,
    allow_switch: bool,
    model: &Tree
) -> (&[(LabeledData<u8, i8>, (f32, f32, usize, usize))], bool)
[src]

pub fn try_switch(&mut self) -> bool[src]

pub fn check_ess_blocking(&mut self)[src]

pub fn reset_scores(&mut self)[src]

pub fn is_empty(&self) -> bool[src]

Auto Trait Implementations

impl RefUnwindSafe for BufferLoader

impl Send for BufferLoader

impl Sync for BufferLoader

impl Unpin for BufferLoader

impl UnwindSafe for BufferLoader

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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

type Err = <U as TryFrom<T>>::Err

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,