NL2code icon indicating copy to clipboard operation
NL2code copied to clipboard

Training on Django

Open jayavardhanr opened this issue 7 years ago • 2 comments

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'

jayavardhanr avatar May 30 '18 03:05 jayavardhanr

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

laila182 avatar Jul 09 '19 14:07 laila182

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.

pcyin avatar Jul 15 '19 17:07 pcyin