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 Freeze for TextData
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