Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 628c651

Browse files
committed
Add explanation for torch.view
1 parent 7b35173 commit 628c651

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

beginner_source/blitz/tensor_tutorial.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@
7979

8080
print(x[:, 1])
8181

82+
###############################################################
83+
# Resizing: If you want to resize/reshape tensor, you can use ``torch.view``:
84+
x = torch.randn(4, 4)
85+
y = x.view(16)
86+
z = x.view(-1, 8) # the size -1 is inferred from other dimensions
87+
print(x.size(), y.size(), z.size())
88+
8289
###############################################################
8390
# **Read later:**
8491
#

0 commit comments

Comments
 (0)