You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/pub/week2/html/week2-reveal.html
+121-2Lines changed: 121 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -215,8 +215,8 @@ <h2 id="overview-of-second-week-january-27-31">Overview of second week, January
215
215
<h2id="videos-on-neural-networks">Videos on Neural Networks </h2>
216
216
217
217
<ul>
218
-
<p><li><ahref="https://www.youtube.com/watch?v=CqOfi41LfDw" target="_blank">Video on Neural Networks</a></li>
219
-
<p><li><ahref="https://www.youtube.com/watch?v=Ilg3gGewQ5U" target="_blank">Video on the back propagation algorithm</a></li>
218
+
<p><li>Video on Neural Networks at <ahref="https://www.youtube.com/watch?v=CqOfi41LfDw" target="_blank"><tt>https://www.youtube.com/watch?v=CqOfi41LfDw</tt></a></li>
219
+
<p><li>Video on the back propagation algorithm at <ahref="https://www.youtube.com/watch?v=Ilg3gGewQ5U" target="_blank"><tt>https://www.youtube.com/watch?v=Ilg3gGewQ5U</tt></a></li>
<h2id="and-a-similar-code-using-pytorch">And a similar code using PyTorch </h2>
2836
+
<p>See also Rashkca et al., chapter 11, jupyter-notebook sent separately, from <ahref="https://github.com/rasbt/machine-learning-book" target="_blank">GitHub</a></p>
2837
+
2838
+
2839
+
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
<divclass="highlight" style="background: #eeeedd">
2845
+
<prestyle="font-size: 80%; line-height: 125%;"><spanstyle="color: #228B22"># Simple NN code using PyTorch on the MNIST dataset (this time the 28 x 28 set)</span>
2846
+
<spanstyle="color: #228B22"># The MNIST dataset is loaded using `torchvision.datasets`. The images are transformed to tensors and normalized.</span>
2847
+
<spanstyle="color: #228B22"># A simple feedforward neural network with one hidden layer is defined using `nn.Module`.</span>
2848
+
<spanstyle="color: #228B22"># The model is trained using the Adam optimizer and CrossEntropyLoss. The training loop iterates over the dataset for a specified number of epochs.</span>
2849
+
<spanstyle="color: #228B22"># Note that we don't include additional hyperparameters and the learning rate is set to 0.001. </span>
2850
+
<spanstyle="color: #228B22"># After training, the model is evaluated on the test dataset to compute accuracy.</span>
2851
+
<spanstyle="color: #228B22"># The trained model's weights are saved to a file for later use.</span>
2852
+
<spanstyle="color: #228B22"># To do: add loops over hyperparameters and learning rates</span>
total += labels.size(<spanstyle="color: #B452CD">0</span>)
2931
+
correct += (predicted == labels).sum().item()
2932
+
2933
+
<spanstyle="color: #658b00">print</span>(<spanstyle="color: #CD5555">f'Accuracy of the network on the 10000 test images: {</span><spanstyle="color: #B452CD">100</span> * correct / total<spanstyle="color: #CD5555">:.2f}%'</span>)
2934
+
2935
+
<spanstyle="color: #228B22"># Save the model checkpoint</span>
0 commit comments