GithubHelp home page GithubHelp logo

Comments (3)

bentrevett avatar bentrevett commented on May 11, 2024 2

The issue here is that TorchText doesn't like it when you only provide training data and no test/validation data. train_data is a one element tuple containing your TabularDataset, instead of just being the TabularDataset itself.

A quick fix is to change the following line:

train_data = torchtext.data.TabularDataset.splits(path = './', train = 'enron.csv', format = 'csv', fields = [('text',Text)])

We can just make it read the same dataset again as a test dataset, but then never actually use it:

train_data, _ = torchtext.data.TabularDataset.splits(path = './', train ='enron.csv', test ='enron.csv', format = 'csv', fields = [('text',Text)])

from pytorch-sentiment-analysis.

Ravikiran2611 avatar Ravikiran2611 commented on May 11, 2024

THANK YOU SO MUCH @bentrevett
BUT NOW I GET AN ERROR FOR THE FOLLOWING LINE
for example in train_iterator: print(example)

AttributeError: 'Field' object has no attribute 'vocab'
IS IT BECAUSE I HAVE NOT EXECUTED THE LINE
Text.built_vocab(train_data)
IF SO , IS THERE ANY WAY TO SET THE VOCAB TO THE VOCAB I HAVE BECAUSE I AM USING A PRETRAINED BERT , THAT IS ,IS IT POSSIBLE TO NUMERICALIZE USING THE BERT TOKENIZER
PLS REPLY IF THERE ANY OTHER WAY TO CREATE DATASET AND CREATE BATCHES FOR IT

from pytorch-sentiment-analysis.

bentrevett avatar bentrevett commented on May 11, 2024

Yep, that's the reason for your error. Unfortunately TorchText doesn't have a nice way to load existing vocabularies (yet). See: pytorch/text#439 and pytorch/text#555

from pytorch-sentiment-analysis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.