pcyin / NL2code

A syntactic neural model for parsing natural language to executable code
184 stars 33 forks source link

Training on Django #4

Open jayavardhanr opened 6 years ago

jayavardhanr commented 6 years ago

I am just running the command given in the readme file to train the model on django dataset.

. train.sh django

I get the below error. I haven't able to able to fix this. Is the something you faced? The code runs perfectly for the "hs" dataset.

Traceback (most recent call last):
  File "code_gen.py", line 163, in <module>
    learner.train()
  File "/users/PAS1351/osu9907/NL2code/learner.py", line 111, in train
    bleu, accuracy = evaluation.evaluate_decode_results(self.val_data, decode_results, verbose=False)
  File "/users/PAS1351/osu9907/NL2code/evaluation.py", line 170, in evaluate_decode_results
    bleu_score = sentence_bleu([refer_tokens_for_bleu], pred_tokens_for_bleu, weights=ngram_weights, smoothing_function=sm.method3)
  File "/users/PAS1351/osu9907/envs/nl2code/lib/python2.7/site-packages/nltk/translate/bleu_score.py", line 79, in sentence_bleu
    return corpus_bleu([references], [hypothesis], weights, smoothing_function)
  File "/users/PAS1351/osu9907/envs/nl2code/lib/python2.7/site-packages/nltk/translate/bleu_score.py", line 180, in corpus_bleu
    return bp * math.exp(math.fsum(s))
  File "/users/PAS1351/osu9907/envs/nl2code/lib/python2.7/site-packages/nltk/translate/bleu_score.py", line 178, in <genexpr>
    if p_i.numerator != 0)
AttributeError: 'float' object has no attribute 'numerator'
laila182 commented 5 years ago

hello , i find same error can you tell me solution to this problem ?

pcyin commented 5 years ago

Hi, the django training script can only be used in the Python2 environment, since the target code to generate in this dataset is written in Python 2.