Skip to content

Commit 2b25c19

Browse files
committed
better formatting
1 parent fd984eb commit 2b25c19

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

beginner_source/basics/buildmodel_tutorial.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@
3636
# if available. Let's check to see if `torch.cuda <https://pytorch.org/docs/stable/notes/cuda.html>`_
3737
# or `torch.backends.mps <https://pytorch.org/docs/stable/notes/mps.html>` are available, otherwise we use the CPU.
3838

39-
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
39+
device = (
40+
"cuda"
41+
if torch.cuda.is_available()
42+
else "mps"
43+
if torch.backends.mps.is_available()
44+
else "cpu"
45+
)
4046
print(f"Using {device} device")
4147

4248
##############################################

beginner_source/basics/quickstart_tutorial.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@
8787
# operations in the neural network, we move it to the GPU or MPS if available.
8888

8989
# Get cpu, gpu or mps device for training.
90-
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
90+
device = (
91+
"cuda"
92+
if torch.cuda.is_available()
93+
else "mps"
94+
if torch.backends.mps.is_available()
95+
else "cpu"
96+
)
9197
print(f"Using {device} device")
9298

9399
# Define model

0 commit comments

Comments
 (0)