Skip to content

Commit a6680ba

Browse files
Migrate to f-strings (pytorch#1803)
For consistency Co-authored-by: Holly Sweeney <[email protected]>
1 parent 8dddccc commit a6680ba

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

beginner_source/basics/tensorqs_tutorial.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
# We move our tensor to the GPU if available
114114
if torch.cuda.is_available():
115-
tensor = tensor.to('cuda')
115+
tensor = tensor.to("cuda")
116116

117117

118118
######################################################################
@@ -124,9 +124,9 @@
124124
# **Standard numpy-like indexing and slicing:**
125125

126126
tensor = 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]}")
130130
tensor[:,1] = 0
131131
print(tensor)
132132

@@ -172,7 +172,7 @@
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")
176176
tensor.add_(5)
177177
print(tensor)
178178

0 commit comments

Comments
 (0)