argmax in dynet

60 views
Skip to first unread message

toru...@gmail.com

unread,
Sep 8, 2017, 6:05:05 AM9/8/17
to DyNet Users
Hi all,

I'm using dynet with autobatching, and would like to perform argmax for greedy decoding in encoder-decoder rnn.
However dynet doesn't have built-in argmax, so I need to use np.argmax along with Expression.npvalue() instead, which performs forward propagation such as

=============
y_t = np.argmax(dy.softmax(...).npvalue())

=============

In my understanding, autobatching works well when we wait forward propagation until all graphs in a batch have constructed, so I want to avoid using np.argmax.

Is there any way to do argmax without performing forward propagation, or is my understanding wrong?

Thank you,
Fujino

Graham Neubig

unread,
Sep 8, 2017, 9:07:51 AM9/8/17
to toru...@gmail.com, DyNet Users
This is a known issue, but unfortunately there is no fix yet:
> https://github.com/clab/dynet/issues/719

A PR would certainly be welcome, but it would require non-trivial
refactoring (making the execution engine be able to handle not just
regular Tensors, but also IndexTensors).

Graham
> --
> You received this message because you are subscribed to the Google Groups
> "DyNet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dynet-users...@googlegroups.com.
> To post to this group, send email to dynet...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dynet-users/2bb6b2d3-d7df-4457-8ac7-8d1ed030c1d8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

toru...@gmail.com

unread,
Sep 9, 2017, 11:30:20 AM9/9/17
to DyNet Users
Thank you. I understood.
Reply all
Reply to author
Forward
0 new messages