Christopher
Christopher

Reputation: 277

Rowwise division with batch data

Given a tensor A of shape [?, n, l] and a tensor D of shape [?, n], I want to divide each row of tensor a of shape [n,l] of A by the corresponding scalar of D.

I thought I could somehow do this by using the broadcasting behavior of tf.div. Unfortunatley I am stuck.

Upvotes: 0

Views: 434

Answers (1)

P-Gn
P-Gn

Reputation: 24631

Here you need to extend D to match the dimension of A:

res = A / D[...,tf.newaxis])

Upvotes: 1

Related Questions