typos
This commit is contained in:
@@ -334,7 +334,7 @@ MathJax.Hub.Config({
|
||||
</center>
|
||||
<br>
|
||||
<center>
|
||||
<h4>Nov 3, 2021</h4>
|
||||
<h4>Nov 5, 2021</h4>
|
||||
</center> <!-- date -->
|
||||
<br>
|
||||
|
||||
|
||||
@@ -391,9 +391,9 @@ theta <span style="color: #666666">=</span> np<span style="color: #666666">.</sp
|
||||
<span style="color: #008000; font-weight: bold">for</span> epoch <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span>(n_epochs):
|
||||
<span style="color: #408080; font-style: italic"># Can you figure out a better way of setting up the contributions to each batch?</span>
|
||||
<span style="color: #008000; font-weight: bold">for</span> i <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span>(m):
|
||||
random_index <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<span style="color: #666666">*</span>M:random_index<span style="color: #666666">*</span>M<span style="color: #666666">+</span>M]
|
||||
yi <span style="color: #666666">=</span> y[random_index<span style="color: #666666">*</span>M:random_index<span style="color: #666666">*</span>M<span style="color: #666666">+</span>M]
|
||||
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)
|
||||
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
|
||||
|
||||
@@ -334,7 +334,7 @@ MathJax.Hub.Config({
|
||||
</center>
|
||||
<br>
|
||||
<center>
|
||||
<h4>Nov 3, 2021</h4>
|
||||
<h4>Nov 5, 2021</h4>
|
||||
</center> <!-- date -->
|
||||
<br>
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ MathJax.Hub.Config({
|
||||
</center>
|
||||
<br>
|
||||
<center>
|
||||
<h4>Nov 3, 2021</h4>
|
||||
<h4>Nov 5, 2021</h4>
|
||||
</center> <!-- date -->
|
||||
<br>
|
||||
|
||||
@@ -1633,9 +1633,9 @@ theta = np.random.randn(<span style="color: #B452CD">2</span>,<span style="color
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> epoch <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(n_epochs):
|
||||
<span style="color: #228B22"># Can you figure out a better way of setting up the contributions to each batch?</span>
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(m):
|
||||
random_index = np.random.randint(m)
|
||||
xi = X[random_index*M:random_index*M+M]
|
||||
yi = y[random_index*M:random_index*M+M]
|
||||
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)
|
||||
eta = learning_schedule(epoch*m+i)
|
||||
theta = theta - eta*gradients
|
||||
|
||||
@@ -267,7 +267,7 @@ MathJax.Hub.Config({
|
||||
</center>
|
||||
<br>
|
||||
<center>
|
||||
<h4>Nov 3, 2021</h4>
|
||||
<h4>Nov 5, 2021</h4>
|
||||
</center> <!-- date -->
|
||||
<br>
|
||||
|
||||
@@ -1651,9 +1651,9 @@ theta = np.random.randn(<span style="color: #B452CD">2</span>,<span style="color
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> epoch <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(n_epochs):
|
||||
<span style="color: #228B22"># Can you figure out a better way of setting up the contributions to each batch?</span>
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span>(m):
|
||||
random_index = np.random.randint(m)
|
||||
xi = X[random_index*M:random_index*M+M]
|
||||
yi = y[random_index*M:random_index*M+M]
|
||||
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)
|
||||
eta = learning_schedule(epoch*m+i)
|
||||
theta = theta - eta*gradients
|
||||
|
||||
@@ -344,7 +344,7 @@ MathJax.Hub.Config({
|
||||
</center>
|
||||
<br>
|
||||
<center>
|
||||
<h4>Nov 3, 2021</h4>
|
||||
<h4>Nov 5, 2021</h4>
|
||||
</center> <!-- date -->
|
||||
<br>
|
||||
|
||||
@@ -1728,9 +1728,9 @@ theta <span style="color: #666666">=</span> np<span style="color: #666666">.</sp
|
||||
<span style="color: #008000; font-weight: bold">for</span> epoch <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span>(n_epochs):
|
||||
<span style="color: #408080; font-style: italic"># Can you figure out a better way of setting up the contributions to each batch?</span>
|
||||
<span style="color: #008000; font-weight: bold">for</span> i <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span>(m):
|
||||
random_index <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<span style="color: #666666">*</span>M:random_index<span style="color: #666666">*</span>M<span style="color: #666666">+</span>M]
|
||||
yi <span style="color: #666666">=</span> y[random_index<span style="color: #666666">*</span>M:random_index<span style="color: #666666">*</span>M<span style="color: #666666">+</span>M]
|
||||
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)
|
||||
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
|
||||
|
||||
Binary file not shown.
+902
-547
File diff suppressed because one or more lines are too long
@@ -1039,9 +1039,9 @@ theta = np.random.randn(2,1)
|
||||
for epoch in range(n_epochs):
|
||||
# Can you figure out a better way of setting up the contributions to each batch?
|
||||
for i in range(m):
|
||||
random_index = np.random.randint(m)
|
||||
xi = X[random_index*M:random_index*M+M]
|
||||
yi = y[random_index*M:random_index*M+M]
|
||||
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)
|
||||
eta = learning_schedule(epoch*m+i)
|
||||
theta = theta - eta*gradients
|
||||
|
||||
Reference in New Issue
Block a user