torchtext

Torchtext AttributeError: 'Example' object has no attribute 'text_content'

Deadly 提交于 2020-08-23 05:04:03
问题 I'm working with RNN and using Pytorch & Torchtext. I've got a problem with building vocab in my RNN. My code is as follows: TEXT = Field(tokenize=tokenizer, lower=True) LABEL = LabelField(dtype=torch.float) trainds = TabularDataset( path='drive/{}'.format(TRAIN_PATH), format='tsv', fields=[ ('label_start', LABEL), ('label_end', None), ('title', None), ('symbol', None), ('text_content', TEXT), ]) testds = TabularDataset( path='drive/{}'.format(TEST_PATH), format='tsv', fields=[ ('text_content

Torchtext AttributeError: 'Example' object has no attribute 'text_content'

不羁岁月 提交于 2020-08-23 05:02:16
问题 I'm working with RNN and using Pytorch & Torchtext. I've got a problem with building vocab in my RNN. My code is as follows: TEXT = Field(tokenize=tokenizer, lower=True) LABEL = LabelField(dtype=torch.float) trainds = TabularDataset( path='drive/{}'.format(TRAIN_PATH), format='tsv', fields=[ ('label_start', LABEL), ('label_end', None), ('title', None), ('symbol', None), ('text_content', TEXT), ]) testds = TabularDataset( path='drive/{}'.format(TEST_PATH), format='tsv', fields=[ ('text_content

Iterating over Torchtext.data.BucketIterator object throws AttributeError 'Field' object has no attribute 'vocab'

拜拜、爱过 提交于 2020-02-03 16:28:51
问题 When I try to look into a batch, by printing the next iteration of the BucketIterator object, the AttributeError is thrown. tv_datafields=[("Tweet",TEXT), ("Anger",LABEL), ("Fear",LABEL), ("Joy",LABEL), ("Sadness",LABEL)] train, vld = data.TabularDataset.splits(path="./data/", train="train.csv",validation="test.csv",format="csv", fields=tv_datafields) train_iter, val_iter = BucketIterator.splits( (train, vld), batch_sizes=(64, 64), device=-1, sort_key=lambda x: len(x.Tweet), sort_within_batch

Iterating over Torchtext.data.BucketIterator object throws AttributeError 'Field' object has no attribute 'vocab'

本小妞迷上赌 提交于 2020-02-03 16:27:27
问题 When I try to look into a batch, by printing the next iteration of the BucketIterator object, the AttributeError is thrown. tv_datafields=[("Tweet",TEXT), ("Anger",LABEL), ("Fear",LABEL), ("Joy",LABEL), ("Sadness",LABEL)] train, vld = data.TabularDataset.splits(path="./data/", train="train.csv",validation="test.csv",format="csv", fields=tv_datafields) train_iter, val_iter = BucketIterator.splits( (train, vld), batch_sizes=(64, 64), device=-1, sort_key=lambda x: len(x.Tweet), sort_within_batch

BucketIterator throws 'Field' object has no attribute 'vocab'

▼魔方 西西 提交于 2019-12-23 18:43:52
问题 It's not a new question, references I found without any solution working for me first and second. I'm a newbie to PyTorch, facing AttributeError: 'Field' object has no attribute 'vocab' while creating batches of the text data in PyTorch using torchtext . Following up the book Deep Learning with PyTorch I wrote the same example as explained in the book. Here's the snippet: from torchtext import data from torchtext import datasets from torchtext.vocab import GloVe TEXT = data.Field(lower=True,

AttributeError: 'Field' object has no attribute 'vocab'

六月ゝ 毕业季﹏ 提交于 2019-12-11 01:36:55
问题 Returned iterator of BucketIterator is giving an error. train_iterator = data.BucketIterator.splits( train_data, batch_size=BATCH_SIZE, device=device ) Value of train_data also looks good. print(vars(train_data.examples[10])) {'text': ['plus', "you've", 'added', 'commercials', 'to', 'the', 'experience...', 'tacky.'], 'label': 'positive'} Stack trace: print([x for x in train_iterator]) --------------------------------------------------------------------------- AttributeError Traceback (most