File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 112112
113113# We move our tensor to the GPU if available
114114if torch .cuda .is_available ():
115- tensor = tensor .to (' cuda' )
115+ tensor = tensor .to (" cuda" )
116116
117117
118118######################################################################
124124# **Standard numpy-like indexing and slicing:**
125125
126126tensor = torch .ones (4 , 4 )
127- print (' First row: ' , tensor [0 ])
128- print (' First column: ' , tensor [:, 0 ])
129- print (' Last column:' , tensor [..., - 1 ])
127+ print (f" First row: { tensor [0 ]} " )
128+ print (f" First column: { tensor [:, 0 ]} " )
129+ print (f" Last column: { tensor [..., - 1 ]} " )
130130tensor [:,1 ] = 0
131131print (tensor )
132132
172172# Operations that store the result into the operand are called in-place. They are denoted by a ``_`` suffix.
173173# For example: ``x.copy_(y)``, ``x.t_()``, will change ``x``.
174174
175- print (tensor , " \n " )
175+ print (f" { tensor } \n " )
176176tensor .add_ (5 )
177177print (tensor )
178178
You can’t perform that action at this time.
0 commit comments