nitishsrivastava / deepnet

Implementation of some deep learning algorithms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IndexError: too many indices for array

tengshaofeng opened this issue · comments

hi,nitishsrivastava
when i run the example of multimodal_dbn ,after the output message ''Collecting all representations",there is a problem like this:

Output written in directory /home/tbq/Downloads/flickr/dbn_reps/split_1
Output written in directory /home/tbq/Downloads/flickr/dbn_reps/split_2
Output written in directory /home/tbq/Downloads/flickr/dbn_reps/split_3
Split 1 image_input
Step 500 T_CE: 13.450Traceback (most recent call last):
File "/home/tbq/Downloads/deepnet-master/deepnet/trainer.py", line 60, in
main()
File "/home/tbq/Downloads/deepnet-master/deepnet/trainer.py", line 54, in main
model.Train()
File "/home/tbq/Downloads/deepnet-master/deepnet/neuralnet.py", line 649, in Train
self.Evaluate(validation=True, collect_predictions=collect_predictions)
File "/home/tbq/Downloads/deepnet-master/deepnet/neuralnet.py", line 394, in Evaluate
MAP, prec50, MAP_list, prec50_list = self.ComputeScore(predictions, targets)
File "/home/tbq/Downloads/deepnet-master/deepnet/neuralnet.py", line 429, in ComputeScore
this_ap, this_prec = self.ScoreOneLabel(preds[:,i], targets[:,i])
File "/home/tbq/Downloads/deepnet-master/deepnet/neuralnet.py", line 409, in ScoreOneLabel
targets_sorted = targets[(-preds.T).argsort().flatten(),:]
IndexError: too many indices for array

what i should do?

Try this
targets_sorted = targets[(-preds.T).argsort().flatten()]
instead of using
targets_sorted = targets[(-preds.T).argsort().flatten(),:]

thanks very much.i will try later------------------ 原始邮件 ------------------
发件人: "notifications"notifications@github.com
发送时间: 2014年11月3日(星期一) 晚上9:36
收件人: "nitishsrivastava/deepnet"deepnet@noreply.github.com;
抄送: "tengshaofeng"307149416@qq.com;
主题: Re: [deepnet] IndexError: too many indices for array (#77)

Try this
targets_sorted = targets[(-preds.T).argsort().flatten()]
instead of using
targets_sorted = targets[(-preds.T).argsort().flatten(),:]


Reply to this email directly or view it on GitHub.

It worked for me as well. Thank you!

It works for me. Thank you!