LiberAI / NSpM

🤖 Neural SPARQL Machines for Knowledge Graph Question Answering.
http://aksw.org/Projects/NeuralSPARQLMachines
MIT License
222 stars 86 forks source link

ZeroDivisionError while training #18

Closed marxmit7 closed 5 years ago

marxmit7 commented 5 years ago

File "nmt/model_helper.py", line 444, in compute_perplexity perplexity = utils.safe_exp(total_loss / total_predict_count) ZeroDivisionError: integer division or modulo by zero

theodore3131 commented 5 years ago

Hi, I solved it by modifying the code as below

if total_predict_count > 0:
    perplexity = utils.safe_exp(total_loss / total_predict_count)
  else:
    perplexity = 0

I have done the training process and the model for Inference performs really well. But the thing is, by doing so, we will get

eval test: perplexity 0.00

and the output_test will be empty By the way, there is also a ZeroDivisionError in bleu.py and I changed likewise.

theodore3131 commented 5 years ago

Fixed, pull request has been made