Skip to content

Commit

Permalink
Update content/pytorch/concepts/tensor-operations/terms/index-reduce/…
Browse files Browse the repository at this point in the history
…index-reduce.md

Co-authored-by: Pragati Verma <[email protected]>
  • Loading branch information
mamtawardhani and PragatiVerma18 authored Dec 16, 2024
1 parent 66e7391 commit 8b8ca01
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ target = torch.zeros(2)
source = torch.tensor([1.0, 2.0, 3.0, 4.0])

# Indices mapping source to target
index = torch.tensor([0, 1, 0, 1])
index = torch.tensor([0, 1, 0, 1], dtype=torch.long) # Ensure index tensor is of type 'long'

# Perform in-place reduction using 'mean' along the 0th dimension (rows)
target.index_reduce_(dim=0, index=index, source=source, reduce='mean')
Expand Down

0 comments on commit 8b8ca01

Please sign in to comment.