I have two tensors A, with shape (25, 1010, 7, 512), and B, with shape (10, 7).
I would like to add B to the first 10 slices using the second dimension of A in a way which could be done in Numpy as:
A[:, :10, :, :] += B[np.newaxis, :, :, np.newaxis]
(It's not important that the original tensor be updated, I'd be fine with either an in place update or a new tensor being created).
Of course this can't be done directly in tensorflow, and tf.tensor_scatter_nd_add doesn't seem to work for this case because the slices aren't into the final dimension of the tensor to be updated. Is there any way to accomplish this sparsely, or do I need to pad B out by a factor of 100?
EDIT: I messed up the numpy example when converting it from an in place update to an addition.