I have a real matrix in Theano, and I want to generate a different matrix so that in each column of the new matrix I have one 1.0 and 0.0 otherwise. 1.0 should indicate the location of the maximum value in the input matrix column.
For instance. If as an input
the following matrix is used,1.0 2.0 3.0 5.0
2.1 0.0 4.0 0.0
0.0 3.0 1.0 4.0
The following matrix should be generated as output:
0.0 0.0 0.0 1.0
1.0 0.0 1.0 0.0
0.0 1.0 0.0 0.0
The solution I am using so far is as follows:
tmp = T.max(inp, axis = 0).dimshuffle('x',0)
out = T.switch(T.eq(tmp, inp), 1.0, 0.0)
, , . , , . , - "" ?