Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: index 0 is out of bounds for axis 0 with size 0 train_cws_lstm.py 中报的错,一直没有解决 #57

Open
LubbyAnneLiu opened this issue Apr 22, 2017 · 2 comments

Comments

@LubbyAnneLiu
Copy link

[100] loss: [28.518539]
[200] loss: [17.184589]
[300] loss: [14.19612]
[400] loss: [13.810515]
[500] loss: [11.092119]
[600] loss: [10.731837]
[700] loss: [10.634817]
[800] loss: [8.1204176]
[900] loss: [8.273036]
[1000] loss: [8.4017849]
Traceback (most recent call last):
File "train_cws_lstm_PKU0421.py", line 288, in
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 43, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "train_cws_lstm_PKU0421.py", line 278, in main
model.inp, tX, tY)
File "train_cws_lstm_PKU0421.py", line 224, in test_evaluate
tf_unary_scores_, transMatrix)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/crf/python/ops/crf.py", line 298, in viterbi_decode
trellis[0] = score[0]
IndexError: index 0 is out of bounds for axis 0 with size 0

大神帮帮忙 每次走到test_evaluate()都会报这个错,我看bug出现在crf.py里,实在是不懂,求指点

@koth
Copy link
Owner

koth commented Apr 22, 2017

应该不是bug,可能那个地方没正确传入参数,比如tag数之类的

@LubbyAnneLiu
Copy link
Author

对对对 我知道不是模型的问题 大概就是传参问题 我试着输出了这一步的传入viterbi_decode()函数的参数tf_unary_scores_和
tf_unary_scores_和transMatrix,好像也没啥问题呀。下面是传入的参数。还有可能是什么问题呀?实在是搞不明白~~拜托~
[[ 5.10233212 -0.54984224 -3.3073473 -2.23302674]
[ 5.00223017 1.7417382 -4.27542925 -3.73243022]
[ 0.62986803 3.85293174 -1.22212958 -3.96823788]
[ 0.70197666 -2.35121202 -0.62936413 2.68005323]
[ 2.77736568 -0.27267972 -2.36598563 -0.48937809]
[ 0.8004145 2.19753051 -2.04182363 -1.4268291 ]
[ 1.86268508 -2.15325522 -1.77105057 2.32386279]
[ 4.85579681 -1.55591941 -2.76405716 -1.15710473]]
transMatrix
[[ 0.19105484 0.18477149 -0.04392412 0.21299016]
[-0.58652729 -0.39606482 0.41640422 0.20975219]
[ 0.09511784 0.22878556 0.03559215 0.52470607]
[ 0.66774857 0.75008577 -0.61195064 0.34702992]]
tf_unary_scores_
[[ 1.15849197 2.9072063 -1.57891667 -3.05160451]
[ 1.61692488 -2.64840722 -1.64531779 2.63486719]
[ 5.21047401 -1.04094565 -2.8609128 -2.224334 ]
[ 2.42167044 3.55341673 -2.2693305 -4.78759813]
[-1.05136931 -0.18433641 1.11184239 0.26811025]
[ 1.70061576 -1.69640815 -1.63032782 1.7006048 ]
[ 4.50150728 -2.17166281 -2.26328468 -0.56402373]]
transMatrix
[[ 0.19105484 0.18477149 -0.04392412 0.21299016]
[-0.58652729 -0.39606482 0.41640422 0.20975219]
[ 0.09511784 0.22878556 0.03559215 0.52470607]
[ 0.66774857 0.75008577 -0.61195064 0.34702992]]

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

No branches or pull requests

2 participants