Confusion feedback _add output is table not tensor
cwellsarnold opened this issue · 3 comments
Hi all,
I have a bidirectional LSTM network that I am using for sequence tagging. I'm trying to use the Confusion feedback object. However, in the _add function, the code expects output to be a tensor, but in my case it is a table. This then fails at the output:view() and output:size(1) calls on line 60. When I run my code, the table is equal to my context_size. So, if I have a batch size of 512, six classes, and a context_size of 5, I get a table of five 512x6 tensors.
Perhaps I am configuring my network wrong? Or am I not understanding context_size and rho? I think they are the same thing. Or should context_size=1 for LSTMs and rho = the context window? Even when I try this, the output object in Confusion is still a table of size 1.
My code uses a logsoftmax output, like the NN tutorial (https://github.com/nicholas-leonard/dp/blob/4616f3a2eca5be0cf1500afe5a0a156e277a9c53/doc/neuralnetworktutorial.md), so perhaps it is a different layer?
Thanks for any help!
Related follow-up question, when I try to access the confusion matrix in the epoch_callback function using report.optimizer.feedback.confusion.matrix, every element in the matrix is zero. report.optimizer.feedback.confusion.per_class.accuracy is also a vector of 0s. This happens in the NN tutorial as well. How should one correctly retrieve the confusion matrix for display?
Thanks again!
Figured it out. The first element in the output table for a recurrent model holds the predictions that correspond to batch:targets():forward('b').
I'm printing the confusion matrix from confusion.lua rather than my code, but it seems to work fine.
👍