Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having an issue with saving the model to file #10

Open
ontologist opened this issue Feb 28, 2023 · 1 comment · May be fixed by #16
Open

Having an issue with saving the model to file #10

ontologist opened this issue Feb 28, 2023 · 1 comment · May be fixed by #16

Comments

@ontologist
Copy link

ontologist commented Feb 28, 2023

I get the following error when I run the example in the installation instructions. I think this has to do with different versions of /usr/local/lib/python3.8/dist-packages/gensim/utils.py distribution.


...
INFO: EPOCH 9: training on 36766 raw words (18663 effective words) took 0.1s, 256472 effective words/s
INFO: Word2Vec lifecycle event {'msg': 'training on 367660 raw words (187198 effective words) took 0.8s, 222197 effective words/s', 'datetime': '2023-02-28T22:31:59.019884', 'gensim': '4.3.0', 'python': '3.8.10 (default, Nov 14 2022, 12:59:47) \n[GCC 9.4.0]', 'platform': 'Linux-5.10.147+-x86_64-with-glibc2.29', 'event': 'train'}
INFO: Word2Vec lifecycle event {'params': 'Word2Vec<vocab=768, vector_size=100, alpha=0.025>', 'datetime': '2023-02-28T22:31:59.020002', 'gensim': '4.3.0', 'python': '3.8.10 (default, Nov 14 2022, 12:59:47) \n[GCC 9.4.0]', 'platform': 'Linux-5.10.147+-x86_64-with-glibc2.29', 'event': 'created'}
INFO: Word2Vec lifecycle event {'fname_or_handle': './cache/output', 'separately': 'None', 'sep_limit': 10485760, 'ignore': frozenset(), 'datetime': '2023-02-28T22:31:59.020175', 'gensim': '4.3.0', 'python': '3.8.10 (default, Nov 14 2022, 12:59:47) \n[GCC 9.4.0]', 'platform': 'Linux-5.10.147+-x86_64-with-glibc2.29', 'event': 'saving'}
INFO: not storing attribute cum_table
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/gensim/utils.py", line 764, in save
    _pickle.dump(self, fname_or_handle, protocol=pickle_protocol)
TypeError: file must have a 'write' attribute

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "OWL2Vec_Standalone.py", line 228, in <module>
    model_.save(config['BASIC']['embedding_dir'])
  File "/usr/local/lib/python3.8/dist-packages/gensim/models/word2vec.py", line 1912, in save
    super(Word2Vec, self).save(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/gensim/utils.py", line 767, in save
    self._smart_save(fname_or_handle, separately, sep_limit, ignore, pickle_protocol=pickle_protocol)
  File "/usr/local/lib/python3.8/dist-packages/gensim/utils.py", line 611, in _smart_save
    pickle(self, fname, protocol=pickle_protocol)
  File "/usr/local/lib/python3.8/dist-packages/gensim/utils.py", line 1442, in pickle
    with open(fname, 'wb') as fout:  # 'b' for binary, needed on Windows
  File "/usr/local/lib/python3.8/dist-packages/smart_open/smart_open_lib.py", line 177, in open
    fobj = _shortcut_open(
  File "/usr/local/lib/python3.8/dist-packages/smart_open/smart_open_lib.py", line 363, in _shortcut_open
    return _builtin_open(local_path, mode, buffering=buffering, **open_kwargs)
IsADirectoryError: [Errno 21] Is a directory: './cache/output'

It seems that the 'fname_or_handle' parameter is not of the right kind. It is supposed to be a file object, for what I understand, but it is a string. The code that calls this is the OWL2Vec_Standalone.py script. I don't know how to fix this. Can you help, please?

@ernestojimenezruiz
Copy link
Collaborator

I think "output" shoudl exist and perhaps the path is missing a "/" --> "./cache/output/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants