small typo in week40

This commit is contained in:
Morten Hjorth-Jensen
2021-11-22 06:20:15 +01:00
parent 01610bc12d
commit b7ef6f0a03
9 changed files with 229 additions and 229 deletions
+1 -1
View File
@@ -336,7 +336,7 @@ MathJax.Hub.Config({
</center>
<br>
<center>
<h4>Nov 16, 2021</h4>
<h4>Nov 22, 2021</h4>
</center> <!-- date -->
<br>
+1 -1
View File
@@ -396,7 +396,7 @@ theta <span style="color: #666666">=</span> np<span style="color: #666666">.</sp
random_index <span style="color: #666666">=</span> M<span style="color: #666666">*</span>np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>randint(m)
xi <span style="color: #666666">=</span> X[random_index:random_index<span style="color: #666666">+</span>M]
yi <span style="color: #666666">=</span> y[random_index:random_index<span style="color: #666666">+</span>M]
gradients <span style="color: #666666">=</span> (<span style="color: #666666">2.0/</span>M)<span style="color: #666666">*</span>training_gradient(yi, xi, theta)
gradients <span style="color: #666666">=</span> (<span style="color: #666666">1.0/</span>M)<span style="color: #666666">*</span>training_gradient(yi, xi, theta)
eta <span style="color: #666666">=</span> learning_schedule(epoch<span style="color: #666666">*</span>m<span style="color: #666666">+</span>i)
theta <span style="color: #666666">=</span> theta <span style="color: #666666">-</span> eta<span style="color: #666666">*</span>gradients
<span style="color: #008000">print</span>(<span style="color: #BA2121">&quot;theta from own sdg&quot;</span>)
+1 -1
View File
@@ -336,7 +336,7 @@ MathJax.Hub.Config({
</center>
<br>
<center>
<h4>Nov 16, 2021</h4>
<h4>Nov 22, 2021</h4>
</center> <!-- date -->
<br>
+2 -2
View File
@@ -184,7 +184,7 @@ MathJax.Hub.Config({
</center>
<br>
<center>
<h4>Nov 16, 2021</h4>
<h4>Nov 22, 2021</h4>
</center> <!-- date -->
<br>
@@ -1646,7 +1646,7 @@ theta = np.random.randn(<span style="color: #B452CD">2</span>,<span style="color
random_index = M*np.random.randint(m)
xi = X[random_index:random_index+M]
yi = y[random_index:random_index+M]
gradients = (<span style="color: #B452CD">2.0</span>/M)*training_gradient(yi, xi, theta)
gradients = (<span style="color: #B452CD">1.0</span>/M)*training_gradient(yi, xi, theta)
eta = learning_schedule(epoch*m+i)
theta = theta - eta*gradients
<span style="color: #658b00">print</span>(<span style="color: #CD5555">&quot;theta from own sdg&quot;</span>)
+2 -2
View File
@@ -268,7 +268,7 @@ MathJax.Hub.Config({
</center>
<br>
<center>
<h4>Nov 16, 2021</h4>
<h4>Nov 22, 2021</h4>
</center> <!-- date -->
<br>
@@ -1664,7 +1664,7 @@ theta = np.random.randn(<span style="color: #B452CD">2</span>,<span style="color
random_index = M*np.random.randint(m)
xi = X[random_index:random_index+M]
yi = y[random_index:random_index+M]
gradients = (<span style="color: #B452CD">2.0</span>/M)*training_gradient(yi, xi, theta)
gradients = (<span style="color: #B452CD">1.0</span>/M)*training_gradient(yi, xi, theta)
eta = learning_schedule(epoch*m+i)
theta = theta - eta*gradients
<span style="color: #658b00">print</span>(<span style="color: #CD5555">&quot;theta from own sdg&quot;</span>)
+2 -2
View File
@@ -345,7 +345,7 @@ MathJax.Hub.Config({
</center>
<br>
<center>
<h4>Nov 16, 2021</h4>
<h4>Nov 22, 2021</h4>
</center> <!-- date -->
<br>
@@ -1741,7 +1741,7 @@ theta <span style="color: #666666">=</span> np<span style="color: #666666">.</sp
random_index <span style="color: #666666">=</span> M<span style="color: #666666">*</span>np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>randint(m)
xi <span style="color: #666666">=</span> X[random_index:random_index<span style="color: #666666">+</span>M]
yi <span style="color: #666666">=</span> y[random_index:random_index<span style="color: #666666">+</span>M]
gradients <span style="color: #666666">=</span> (<span style="color: #666666">2.0/</span>M)<span style="color: #666666">*</span>training_gradient(yi, xi, theta)
gradients <span style="color: #666666">=</span> (<span style="color: #666666">1.0/</span>M)<span style="color: #666666">*</span>training_gradient(yi, xi, theta)
eta <span style="color: #666666">=</span> learning_schedule(epoch<span style="color: #666666">*</span>m<span style="color: #666666">+</span>i)
theta <span style="color: #666666">=</span> theta <span style="color: #666666">-</span> eta<span style="color: #666666">*</span>gradients
<span style="color: #008000">print</span>(<span style="color: #BA2121">&quot;theta from own sdg&quot;</span>)
Binary file not shown.
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1048,7 +1048,7 @@ for epoch in range(n_epochs):
random_index = M*np.random.randint(m)
xi = X[random_index:random_index+M]
yi = y[random_index:random_index+M]
gradients = (2.0/M)*training_gradient(yi, xi, theta)
gradients = (1.0/M)*training_gradient(yi, xi, theta)
eta = learning_schedule(epoch*m+i)
theta = theta - eta*gradients
print("theta from own sdg")