pub struct TextData { /* private fields */ }
Expand description
Text data holder.
Implementations
sourceimpl 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ⓘNotable traits for TextDataIterimpl Iterator for TextDataIter type Item = Tensor;
pub fn iter_shuffle(&self, seq_len: i64, batch_size: i64) -> TextDataIterⓘNotable traits for TextDataIterimpl Iterator for TextDataIter type Item = Tensor;
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more