Skip to content

Commit 9468c0a

Browse files
[skip ci] Update MNIST_on_TPU.ipynb (#2252)
* Update MNIST_on_TPU.ipynb * applied suggestions Co-authored-by: vfdev <vfdev.5@gmail.com>
1 parent fc5580a commit 9468c0a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/notebooks/MNIST_on_TPU.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
"id": "4mnaxX3eXNGd"
6868
},
6969
"source": [
70-
"VERSION = \"1.5\"\n",
71-
"!curl https://raw.githubusercontent.com/pytorch/xla/master/contrib/scripts/env-setup.py -o pytorch-xla-env-setup.py\n",
72-
"!python pytorch-xla-env-setup.py --version $VERSION"
70+
"VERSION = !curl -s https://api.github.com/repos/pytorch/xla/releases/latest | grep -Po '\"tag_name\": \"v\\K.*?(?=\")'\n",
71+
"VERSION = VERSION[0].rstrip('.0') # remove trailing zero\n",
72+
"!pip install cloud-tpu-client==0.10 https://storage.googleapis.com/tpu-pytorch/wheels/torch_xla-{VERSION}-cp37-cp37m-linux_x86_64.whl"
7373
],
7474
"execution_count": null,
7575
"outputs": []
@@ -345,7 +345,7 @@
345345
" avg_accuracy = metrics[\"accuracy\"]\n",
346346
" avg_nll = metrics[\"nll\"]\n",
347347
" pbar.log_message(\n",
348-
" \"Training Results - Epoch: {engine.state.epoch} Avg accuracy: {avg_accuracy:.2f} Avg loss: {avg_nll:.2f}\"\n",
348+
" f\"Training Results - Epoch: {engine.state.epoch} Avg accuracy: {avg_accuracy:.2f} Avg loss: {avg_nll:.2f}\"\n",
349349
" )\n",
350350
" writer.add_scalar(\"training/avg_loss\", avg_nll, engine.state.epoch)\n",
351351
" writer.add_scalar(\"training/avg_accuracy\", avg_accuracy, engine.state.epoch)\n",
@@ -358,7 +358,7 @@
358358
" avg_accuracy = metrics[\"accuracy\"]\n",
359359
" avg_nll = metrics[\"nll\"]\n",
360360
" print(\n",
361-
" \"Validation Results - Epoch: {engine.state.epoch} Avg accuracy: {avg_accuracy:.2f} Avg loss: {avg_nll:.2f}\"\n",
361+
" f\"Validation Results - Epoch: {engine.state.epoch} Avg accuracy: {avg_accuracy:.2f} Avg loss: {avg_nll:.2f}\"\n",
362362
" )\n",
363363
" writer.add_scalar(\"valdation/avg_loss\", avg_nll, engine.state.epoch)\n",
364364
" writer.add_scalar(\"valdation/avg_accuracy\", avg_accuracy, engine.state.epoch)"
@@ -395,4 +395,4 @@
395395
"outputs": []
396396
}
397397
]
398-
}
398+
}

0 commit comments

Comments
 (0)