question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError from FastText

See original GitHub issue

Hello. I recently installed Torchtext 0.3.1 and tqdm 4.32.1 and tried to use FastText. However, the following error occurred:

torchtext.vocab.FastText() 0%| | 0/1 [00:00<?, ?it/s] Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/home/ros-slam/.local/lib/python3.5/site-packages/torchtext/vocab.py”, line 411, in init super(FastText, self).init(name, url=url, **kwargs) File “/home/ros-slam/.local/lib/python3.5/site-packages/torchtext/vocab.py”, line 280, in init self.cache(name, cache, url=url, max_vectors=max_vectors) File “/home/ros-slam/.local/lib/python3.5/site-packages/torchtext/vocab.py”, line 370, in cache vectors[vectors_loaded] = torch.tensor([float(x) for x in entries]) File “/home/ros-slam/.local/lib/python3.5/site-packages/torchtext/vocab.py”, line 370, in <listcomp> vectors[vectors_loaded] = torch.tensor([float(x) for x in entries]) ValueError: could not convert string to float: b’version=“1.0”’

To find the cause of ValueError, I checked the vocab.py

class FastText(Vectors):

    url_base = 'https://s3-us-west-1.amazonaws.com/fasttext-vectors/wiki.{}.vec'

    def __init__(self, language="en", **kwargs):
        url = self.url_base.format(language)
        name = os.path.basename(url)
        super(FastText, self).__init__(name, url=url, **kwargs)

It is assumed that the cause of this error occurred while accessing that website ‘url_base’. So, how can we solve this error? I’ve looked here for a case of a similar problem to mine, but unfortunately it doesn’t appear to be an unusual case. I’ve also tried the code in 0.2.3 versions, but the same thing is happening.

Thank you in advance for your reply.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
zhangguanheng66commented, Jun 4, 2019

I just did a quick test with torchtext-0.4.0 and didn’t have a problem to load torchtext.vocab.FastText(). If possible, please clone the master branch from GitHub and install it with command “python setup.py install”. It’s pretty straightforward.

1reaction
justice-suricommented, Jun 4, 2019

I just upgraded urllib3 and chardet and warning was disappeared. But error still occured.

Read more comments on GitHub >

github_iconTop Results From Across the Web

fasttext says cannot be opened for training - Stack Overflow
The problem here is that the train methods from fasttext expect a training file, and you are sending a string instead of a...
Read more >
model cannot be opened for loading · Issue #1034 - GitHub
I downloaded the file from: https://fasttext.cc/docs/en/crawl-vectors.html. The traceback: ValueError Traceback (most recent call last)
Read more >
Python module - fastText
In this document we present how to use fastText in python. Table of contents. Requirements; Installation; Usage overview. Word representation model; Text ...
Read more >
Source code for models.fasttext_mod - RedditScore Overview
_model = fastText.load_model( os.path.splitext(filepath)[0] + '.bin') return model ... str): doc += X[i] else: raise ValueError( 'X has to be a sequence of ......
Read more >
How to use the fasttext.load_model function in fasttext - Snyk
request.urlretrieve(url, opt['fasttext_model']) print('Downloaded a fasttext model') except Exception as ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found