LoginSignup
0
0

More than 5 years have passed since last update.

今日、pythonで出たエラー

Last updated at Posted at 2018-12-20

「ゼロから作るDeep Learning2自然言語処理編」斎藤 康毅 著

のプログラムをdockerで利用できるようにしている。

dockerで機械学習(2)with anaconda(2)「ゼロから作るDeep Learning2自然言語処理編」斎藤 康毅 著https://qiita.com/kaizen_nagoya/items/3b80dfc76933cea522c6


train_better_rnnlm.py
を日本語を読めるようにした。

動かすと次のエラーがでた。

evaluating perplexity ...

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-49-42de959ae3a3> in <module>()
      1 # テストデータでの評価
      2 model.reset_state()
----> 3 ppl_test = eval_perplexity(model, corpus_test)
      4 print('test perplexity: ', ppl_test)

~\NLP練習\deep-learning-from-scratch-2-master\common\util.py in eval_perplexity(model, corpus, batch_size, time_size)
    221 
    222     print('')
--> 223     ppl = np.exp(total_loss / max_iters)
    224     return ppl
    225 

ZeroDivisionError: division by zero

max_itersは、
common.trainer.py

max_iters = data_size // batch_size

ファイルを読み込めてない場合は、
data_size = len(x)
でいれているdata_sizeが0になる。

データのあるはずの時も出たらしい。
デバッグ中。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0