Giter Site home page Giter Site logo

nlp-beginner_solution's Issues

task2的dataset失效了

不知道是不是因为时效的原因, task2dataset 和文件名不完全匹配, 可以修改一下

在我把文件名改成 train.tsvtest.tsv 之后

运行这段代码的时候

#构建词典,字符映射到embedding
#TEXT.vocab.vectors 就是词向量
TEXT.build_vocab(train_data,  vectors= 'glove.6B.50d',   #可以提前下载好
                 unk_init= lambda x:torch.nn.init.uniform_(x, a=-0.25, b=0.25))
LABEL.build_vocab(train_data)


#得到索引,PAD_TOKEN='<pad>'
PAD_INDEX = TEXT.vocab.stoi[PAD_TOKEN]
TEXT.vocab.vectors[PAD_INDEX] = 0.0

colab上提示这个

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-58-88fe1b0b4be6> in <module>()
      3 
      4 TEXT.build_vocab(train_data, vectors= 'glove.6B.50d',   #可以提前下载好
----> 5                  unk_init= lambda x:torch.nn.init.uniform_(x, a=-0.25, b=0.25))
      6 LABEL.build_vocab(train_data)
      7 

1 frames
/usr/local/lib/python3.7/dist-packages/torchtext/legacy/data/field.py in build_vocab(self, *args, **kwargs)
    290                 sources.append(arg)
    291         for data in sources:
--> 292             for x in data:
    293                 if not self.sequential:
    294                     x = [x]

/usr/local/lib/python3.7/dist-packages/torchtext/legacy/data/dataset.py in __getattr__(self, attr)
    152         if attr in self.fields:
    153             for x in self.examples:
--> 154                 yield getattr(x, attr)
    155 
    156     @classmethod

AttributeError: 'Example' object has no attribute 'Phrase'

不知道是什么原因

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.