Issue
Let's say I have two numpy arrays a[n,3]
and b[m,3]
How do I calculate c[n,m,3]
, without resorting to a for
loop, such as:
c[i,j,:] = a[i,:] + b[j,:]
Solution
Try this:
c = a[:, None, :] + b[None, :, :]
Answered By - Abhinav Goyal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.