pub struct TextData { /* private fields */ }
Expand description
Text data holder.
Implementations§
source§impl TextData
impl TextData
sourcepub fn new<P: AsRef<Path>>(filename: P) -> Result<TextData, TchError>
pub fn new<P: AsRef<Path>>(filename: P) -> Result<TextData, TchError>
Creates a text dataset from a file.
sourcepub fn labels(&self) -> i64
pub fn labels(&self) -> i64
Returns the number of different characters/labels used by the dataset.
pub fn label_to_char(&self, label: i64) -> char
pub fn char_to_label(&self, c: char) -> Result<u8, TchError>
sourcepub fn iter_shuffle(&self, seq_len: i64, batch_size: i64) -> TextDataIter ⓘ
pub fn iter_shuffle(&self, seq_len: i64, batch_size: i64) -> TextDataIter ⓘ
Returns a batch iterator over the dataset. Each sample is made of seq_len characters.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for TextData
impl Send for TextData
impl !Sync for TextData
impl Unpin for TextData
impl UnwindSafe for TextData
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