Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

ValueError: Function has keyword-only parameters or annotations, use inspect.signature() API which can support them #196

Open
patrickdrouin opened this issue Jan 29, 2023 · 3 comments

Comments

@patrickdrouin
Copy link

I'm running into issues when trying to execute the unsupervised alignement (Python 3.8.16) :

python MUSE-main/unsupervised.py --src_lang en --tgt_lang fr --src_emb corpus_en.tag.bin --tgt_emb corpus_fr.tag.bin --n_refinement 5 --emb_dim 100
INFO - 01/29/23 17:30:10 - 0:00:00 - ============ Initialized logger ============
INFO - 01/29/23 17:30:10 - 0:00:00 - adversarial: True
batch_size: 32
cuda: True
dico_build: S2T
dico_eval: default
dico_max_rank: 15000
dico_max_size: 0
dico_method: csls_knn_10
dico_min_size: 0
dico_threshold: 0
dis_clip_weights: 0
dis_dropout: 0.0
dis_hid_dim: 2048
dis_input_dropout: 0.1
dis_lambda: 1
dis_layers: 2
dis_most_frequent: 75000
dis_optimizer: sgd,lr=0.1
dis_smooth: 0.1
dis_steps: 5
emb_dim: 100
epoch_size: 1000000
exp_id:
exp_name: debug
exp_path: /part/02/data/me/metavirt/MUSE-main/dumped/debug/1gyrk6dihw
export: txt
lr_decay: 0.98
lr_shrink: 0.5
map_beta: 0.001
map_id_init: True
map_optimizer: sgd,lr=0.1
max_vocab: 200000
min_lr: 1e-06
n_epochs: 5
n_refinement: 5
normalize_embeddings:
seed: -1
src_emb: corpus_en.tag.bin
src_lang: en
tgt_emb: corpus_fr.tag.bin
tgt_lang: fr
verbose: 2
INFO - 01/29/23 17:30:10 - 0:00:00 - The experiment will be stored in /part/02/data/me/metavirt/MUSE-main/dumped/debug/1gyrk6dihw
INFO - 01/29/23 17:30:11 - 0:00:01 - Loaded binary model. Generating embeddings ...
INFO - 01/29/23 17:30:13 - 0:00:02 - Generated embeddings for 39391 words.
INFO - 01/29/23 17:30:14 - 0:00:03 - Loaded binary model. Generating embeddings ...
INFO - 01/29/23 17:30:16 - 0:00:06 - Generated embeddings for 56481 words.
Traceback (most recent call last):
File "MUSE-main/unsupervised.py", line 96, in
trainer = Trainer(src_emb, tgt_emb, mapping, discriminator, params)
File "/part/02/data/me/metavirt/MUSE-main/src/trainer.py", line 41, in init
optim_fn, optim_params = get_optimizer(params.map_optimizer)
File "/part/02/data/me/metavirt/MUSE-main/src/utils.py", line 218, in get_optimizer
expected_args = inspect.getargspec(optim_fn.init)[0]
File "/usr/lib/python3.8/inspect.py", line 1095, in getargspec
raise ValueError("Function has keyword-only parameters or annotations"
ValueError: Function has keyword-only parameters or annotations, use inspect.signature() API which can support them

Any ideas or suggestions to fix this?

@mjdaoudi
Copy link

Hello Patrick, on my end, I went into the utils.py(line 218) file and changed expected_args = inspect.getargspec(optim_fn.init)[0] into expected_args = inspect.getfullargspec(optim_fn.__init__)[0]. After that, it went fine.

@jiaohuix
Copy link

Hello Patrick, on my end, I went into the utils.py(line 218) file and changed expected_args = inspect.getargspec(optim_fn.init)[0] into expected_args = inspect.getfullargspec(optim_fn.__init__)[0]. After that, it went fine.

cool!!! it does work!!!

@sinaahmadi
Copy link

I tried your suggestion but now get this error:

assert mf <= min(len(self.src_dico), len(self.tgt_dico))
AssertionError

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

No branches or pull requests

4 participants