darkonhub / darkon-examples

Examples for darkon
Apache License 2.0
16 stars 3 forks source link

Error while get top5_result in GradcamDemo #5

Open MacwinWin opened 6 years ago

MacwinWin commented 6 years ago

When I run the /darkon-examples/GradcamDemo.ipynb, I got the error below:

`IndexError Traceback (most recent call last)

in () 1 probs = insp._prob_ts 2 probs_eval = sess.run(probs,feed_dict={inputs:np.reshape(image1,(1,224,224,3))}) ----> 3 top5_result = imagenet_decoder(probs_eval) 4 print(top5_result) ~/darkon-examples-master/gradcam/imagenet_decoder.py in imagenet_decoder(preds, top) 1007 result = [] 1008 for i in range(top): -> 1009 result.append((class_names[top_indices[i]], top_indices[i])) 1010 return result IndexError: index 1 is out of bounds for axis 0 with size 1`

I'm using tensorflow 1.5.0

MacwinWin commented 6 years ago

I solved this error by change

preds_sort = np.argsort(preds[0][0])

to

preds_sort = np.argsort(preds[0])

in file "imagenet_decoder.py"

zironycho commented 6 years ago

Thank you for reporting and solving this issue!