Skip to content

Broadcast array on specific indices only #18400

Answered by soraros
jstpierref asked this question in Q&A
Discussion options

You must be logged in to vote

Try these:

A = jnp.array([[-1, -1, -1], [-1, 16, -1], [-1, -1, -1]]) / 8.0
I = jnp.eye(3)
k0 = jnp.tensordot(A, I, axes=((), ()))
k1 = jnp.einsum('ij,kl->ijkl', A, I)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jstpierref
Comment options

Answer selected by jstpierref
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants