简体   繁体   中英

how to use dot production on batch data?

I am trying to apply tanh(dot(x,y)) ; x and y are batch data of my RNN.

x,y have shape (n_batch, n_length, n_dim) like (2,3,4) ; 2 samples with 3 sequences, each is 4 dimensions.

I want to do inner or dot production to last dimension. Then tanh(dot(x,y)) should have shape of (n_batch, n_length) = (2, 3)

Which function should I use?

This expression should do the trick:

theano.tensor.tanh((x * y).sum(2))

The dot product is computed 'manually' by doing element-wise multiplication, then summing over the last dimension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM