Hacker News new | ask | show | jobs
by im3w1l 2126 days ago
I recommend

X + Y[:, tf.newaxis]

For higher dimensions of Y, you can use (but it might be ill-advised)

X + Y[:, tf.newaxis, ...]

1 comments

Sure! The desire for fancier notation is from more complicated examples, the kind where you write elaborate comments to explain why you're permuting 3rd & 4th dim of B to line up with C and part of D.