Skip to content

Commit

Permalink
kinda complete draft of week 2
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterNg15 committed Feb 7, 2023
1 parent 15bbe6c commit 00fd293
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
11 changes: 6 additions & 5 deletions Lecture Notes/Lec2/lec2.fdb_latexmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Fdb version 3
["pdflatex"] 1675660729 "d:/School/University/_UCA/cs389/public_repo/Lecture Notes/Lec2/lec2.tex" "lec2.pdf" "lec2" 1675660732
["pdflatex"] 1675751038 "d:/School/University/_UCA/cs389/public_repo/Lecture Notes/Lec2/lec2.tex" "lec2.pdf" "lec2" 1675751042
"C:/Users/PeterNg/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map" 1675106754 80937 91001db6d4ae332437b4b739862cda02 ""
"C:/Users/PeterNg/AppData/Local/MiKTeX/miktex/data/le/pdftex/pdflatex.fmt" 1643486774 10244413 6f29d7d7ffced9ecc4d022246ecc2028 ""
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/tfm/jknappen/ec/ectt1000.tfm" 993058740 1348 d70ddf2d5d512b838e50a335e385e919 ""
Expand Down Expand Up @@ -47,6 +47,7 @@
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmsy8.pfb" 1247593067 32626 5abc8bb2f28aa647d4c70f8ea38cc0d3 ""
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmti10.pfb" 1247593067 37944 359e864bd06cde3b1cf57bb20757fb06 ""
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmtt10.pfb" 1247593067 31099 342ef5a582aacbd3346f3cf4579679fa ""
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/symbols/msam10.pfb" 1247593073 31764 459c573c03a4949a528c2cc7f557e217 ""
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/symbols/msbm10.pfb" 1247593073 34694 870c211f62cb72718a00e353f14f254d ""
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/tex/context/base/mkii/supp-pdf.mkii" 1580390158 71627 94eb9990bed73c364d7f53f960cc8c5b ""
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/tex/generic/atbegshi/atbegshi.sty" 1575571100 24708 5584a51a7101caf7e6bbf1fc27d8f7b1 ""
Expand Down Expand Up @@ -183,10 +184,10 @@
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/tex/latex/url/url.sty" 1388490452 12796 8edb7d69a20b857904dd0ea757c14ec9 ""
"C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/tex/latex/xcolor/xcolor.sty" 1636284872 56029 3f7889dab51d620aa43177c391b7b190 ""
"Figs/linear_classifer.png" 1675645865 12047 37e8382e8bed165b046b997cf7e77ac3 ""
"d:/School/University/_UCA/cs389/public_repo/Lecture Notes/Lec2/lec2.tex" 1675660728 10479 767dbdb047dd3a128e2a3734342c2fc7 ""
"lec2.aux" 1675660732 2518 be74802fb0d9a6c15a829d021ca0f2bf "pdflatex"
"lec2.out" 1675660732 1229 1e8575f9400f0913c5ab46665b89fd5d "pdflatex"
"lec2.tex" 1675660728 10479 767dbdb047dd3a128e2a3734342c2fc7 ""
"d:/School/University/_UCA/cs389/public_repo/Lecture Notes/Lec2/lec2.tex" 1675751034 11192 755a2e0f5019f648126b2177e713022a ""
"lec2.aux" 1675751042 2518 be74802fb0d9a6c15a829d021ca0f2bf "pdflatex"
"lec2.out" 1675751042 1229 1e8575f9400f0913c5ab46665b89fd5d "pdflatex"
"lec2.tex" 1675751034 11192 755a2e0f5019f648126b2177e713022a ""
(generated)
"lec2.aux"
"lec2.log"
Expand Down
2 changes: 2 additions & 0 deletions Lecture Notes/Lec2/lec2.fls
Original file line number Diff line number Diff line change
Expand Up @@ -1015,5 +1015,7 @@ INPUT C:\Users\PeterNg\AppData\Local\Programs\MiKTeX\fonts\type1\public\amsfonts
INPUT C:\Users\PeterNg\AppData\Local\Programs\MiKTeX\fonts\type1\public\amsfonts\cm\cmti10.pfb
INPUT C:\Users\PeterNg\AppData\Local\Programs\MiKTeX\fonts\type1\public\amsfonts\cm\cmtt10.pfb
INPUT C:\Users\PeterNg\AppData\Local\Programs\MiKTeX\fonts\type1\public\amsfonts\cm\cmtt10.pfb
INPUT C:\Users\PeterNg\AppData\Local\Programs\MiKTeX\fonts\type1\public\amsfonts\symbols\msam10.pfb
INPUT C:\Users\PeterNg\AppData\Local\Programs\MiKTeX\fonts\type1\public\amsfonts\symbols\msam10.pfb
INPUT C:\Users\PeterNg\AppData\Local\Programs\MiKTeX\fonts\type1\public\amsfonts\symbols\msbm10.pfb
INPUT C:\Users\PeterNg\AppData\Local\Programs\MiKTeX\fonts\type1\public\amsfonts\symbols\msbm10.pfb
24 changes: 12 additions & 12 deletions Lecture Notes/Lec2/lec2.log
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX 21.12.10) (preloaded format=pdflatex 2022.1.29) 6 FEB 2023 00:18
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX 21.12.10) (preloaded format=pdflatex 2022.1.29) 7 FEB 2023 01:23
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
Expand Down Expand Up @@ -644,20 +644,20 @@ File: umsb.fd 2013/01/14 v3.01 AMS symbols B
) [1

{C:/Users/PeterNg/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map}]
<./Figs/linear_classifer.png, id=71, 329.23pt x 329.23pt>
<./Figs/linear_classifer.png, id=72, 329.23pt x 329.23pt>
File: ./Figs/linear_classifer.png Graphic file (type png)
<use ./Figs/linear_classifer.png>
Package pdftex.def Info: ./Figs/linear_classifer.png used on input line 144.
(pdftex.def) Requested size: 227.62204pt x 227.62608pt.
[2 <./Figs/linear_classifer.png>]
Package hyperref Info: bookmark level for unknown algorithm defaults to 0 on input line 175.

Underfull \hbox (badness 6428) in paragraph at lines 210--211
Underfull \hbox (badness 6428) in paragraph at lines 217--218
[]\OT1/cmr/m/n/10.95 MIT Open Learn-ing Li-brary, 6.036, Spring 2020, [][]$\OT1/cmtt/m/n/10.95 https : / / openlearninglibrary .
[]


Underfull \hbox (badness 10000) in paragraph at lines 210--211
Underfull \hbox (badness 10000) in paragraph at lines 217--218
\OT1/cmtt/m/n/10.95 mit . edu / assets / courseware / v1 / 2481f8f2964716032b134db99e369b81 / asset-[]v1 :
[]

Expand All @@ -666,17 +666,17 @@ Package rerunfilecheck Info: File `lec2.out' has not changed.
(rerunfilecheck) Checksum: 1E8575F9400F0913C5AB46665B89FD5D;1229.
)
Here is how much of TeX's memory you used:
23468 strings out of 478593
440843 string characters out of 2843660
712940 words of memory out of 3000000
23470 strings out of 478593
440867 string characters out of 2843660
712941 words of memory out of 3000000
41211 multiletter control sequences out of 15000+600000
478801 words of font info for 64 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
84i,19n,80p,673b,761s stack positions out of 5000i,500n,10000p,200000b,80000s
<C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmbx10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmbx12.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmbxti10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmex10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi6.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi8.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi9.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr6.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr8.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr9.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmsy10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmsy8.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmti10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmtt10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/symbols/msbm10.pfb>
Output written on lec2.pdf (3 pages, 236331 bytes).
84i,19n,80p,765b,761s stack positions out of 5000i,500n,10000p,200000b,80000s
<C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmbx10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmbx12.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmbxti10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmex10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi6.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi8.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmmi9.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr6.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr8.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr9.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmsy10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmsy8.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmti10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmtt10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/symbols/msam10.pfb><C:/Users/PeterNg/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/symbols/msbm10.pfb>
Output written on lec2.pdf (3 pages, 247065 bytes).
PDF statistics:
183 PDF objects out of 1000 (max. 8388607)
36 named destinations out of 1000 (max. 500000)
194 PDF objects out of 1000 (max. 8388607)
38 named destinations out of 1000 (max. 500000)
74 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file modified Lecture Notes/Lec2/lec2.pdf
Binary file not shown.
Binary file modified Lecture Notes/Lec2/lec2.synctex.gz
Binary file not shown.
27 changes: 17 additions & 10 deletions Lecture Notes/Lec2/lec2.tex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

\section{Neural Networks (lecture 3)}

\begin{definition}[Multi-dimensional data] A \emph{multi-dimensional data} has $n$ number of data and $d$ number of features and can be written as\footnote{Note that this array is transposed because $X$ is a row vector and each $X^{(i)}$ is a d-dimensional column vector}:
\begin{definition}[Multi-dimensional data] A \emph{multi-dimensional data} that has $n$ number of data with $d$ number of features can be written as\footnote{Note that this array is transposed because $X$ is a row vector and each $X^{(i)}$ is a d-dimensional column vector}:
\begin{align}
X = \left [ X^{(1)}, X^{(2)}, ..., X^{(n)} \right ]^{T}
\end{align}
Expand All @@ -66,7 +66,7 @@ \section{Neural Networks (lecture 3)}
\end{align}
Putting all this together, our multi dimensional data is a matrix with dimensions $(n \times d)$:
\begin{align}
\begin{bmatrix}
X = \begin{bmatrix}
X_{1}^{(1)} & \cdots & X_{d}^{(1)} \\
\vdots & \ddots & \vdots \\
X_{1}^{(n)} & \cdots & X_{d}^{(n)}
Expand All @@ -78,7 +78,7 @@ \section{Neural Networks (lecture 3)}

\subsection{Perceptron}
\begin{definition}[Perceptron]

A \emph{perceptron} is a computational model of a biological neuron. A graphical visualization of a perceptron can be seen in \autoref{fig:perceptron},
\end{definition}

\begin{figure}[h]
Expand Down Expand Up @@ -112,7 +112,7 @@ \subsection{Perceptron}
\label{fig:perceptron}
\end{figure}

where the vertices $X_i$ are the inputs, the edges $W_i$ are the weighted connections, the vertex $b$ is the bias term, and the vertex $Y'$ is the output. We can be write this mathematically as:
where the vertices $X_i$ are the input features, the edges $W_i$ are the weighted connections, the vertex $b$ is the bias term, and the vertex $Y'$ is the output. We can be write this mathematically as:
\begin{align}
Y' = \phi(W^{T}X + b)
\end{align}
Expand Down Expand Up @@ -158,17 +158,17 @@ \subsection{Linear Separability}
\emph{If the dataset, $D$, is linearly separable, then the perceptron algorithm is guaranteed to find a linear separator} \cite{MIT}
\end{theorem}

How would one \emph{formally describe linear separabilty?} This is beyond the scope for this class, but you can refer to this \href{https://openlearninglibrary.mit.edu/assets/courseware/v1/8f4f9aca5581dde50291b0d0e29d0148/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_The_Perceptron.pdf}{MIT lecture notes} for a detailed explanation. The intuition is if the shortest distance of a point to the hyperplane (the norm) is positive for all points then the dataset is classifed correctly. You can use \autoref{fig:linear_classifier} to help with this visualization.
How would one \emph{formally describe linear separability?} This is beyond the scope for this class, but you can refer to this \href{https://openlearninglibrary.mit.edu/assets/courseware/v1/8f4f9aca5581dde50291b0d0e29d0148/asset-v1:MITx+6.036+1T2019+type@asset+block/notes_chapter_The_Perceptron.pdf}{MIT lecture notes (pg. 4)} for a detailed explanation. The intuition is if the shortest distance of a point to the hyperplane (the norm) is positive for all points then the dataset is classified correctly. You can use \autoref{fig:linear_classifier} to help with this visualization. Understanding this helps us understand why the perceptron is unable to solve XOR.

\subsection{Regression}

\begin{definition}[Regression]
Predict continous outputs ($\hat{y} \in \mathbb{R}$) that are close to the true values
Predict continuous outputs ($\hat{y} \in \mathbb{R}$) that are close to the true values
\end{definition}

\section{Stochastic Gradient Descent implementation (lecture 4)}

Hopefully, we now have a mathematical understanding and an intuition of all the main components of a supervised machine learning model. We can now start implementing a very simple SGD. Recall that in a SGD, we want to update the parameters $W$ and $b$ after every single training data.
Hopefully, we now have a mathematical understanding and an intuition of all the main components of a supervised machine learning model. We can now start implementing a very simple SGD. Recall that in a SGD, we want to update the parameters $W$ and $b$ after every single training data.

% SGD algorithm
\begin{algorithm}
Expand All @@ -178,7 +178,7 @@ \section{Stochastic Gradient Descent implementation (lecture 4)}
\For{$X^{(i)}$ in $X$} \Comment{loop through entire dataset}
\State{$\hat{y}^{(i)} = F_{W}(X^{(i)}) = X^{(i)}W^{T} + b$} \Comment{our model's prediction for input $X^{(i)}$}
\State{Loss$^{(i)} =$ MSE$(y^{(i)}, \hat{y}^{(i)}) = \frac{1}{2} \sum{(y^{(i)} - \hat{y}^{(i)})^{2}}$ } \Comment{calculate loss of prediction with actual}
\State{$W = W - \alpha \nabla_W \text{Loss}^{(i)}$} \Comment{update weight}
\State{$W = W - \alpha \nabla_W \text{Loss}^{(i)} = W - \alpha (X^{(i)} \cdot (\hat{y}^{(i)}-y^{(i)}))$} \Comment{update weight}
\State{$b = b - \alpha \nabla_b \text{Loss}^{(i)}$} \Comment{update bias}
\EndFor
\EndFor
Expand All @@ -198,11 +198,18 @@ \subsection{Calculating Gradient of Loss}
\end{align}
Now recall that $\hat{y} = W^{T}X + b$ and $L = \frac{1}{2} \sum{(y^{(i)} - \hat{y}^{(i)})^{2}}$ , therefore:
\begin{align}
\frac{d \hat{y}}{dW_1} = X_1
\frac{\partial \hat{y}}{\partial W_1} = X_1^{(i)}
\end{align}
\begin{align}
\frac{d \hat{y}}{db} = 1
\frac{\partial \hat{L}}{\partial \hat{y}} = \hat{y}^{(i)} - y^{(i)}
\end{align}
\begin{align}
\nabla_W \text{Loss} = \frac{\partial L}{\partial W} = \left[ X_1^{(i)} \cdot (\hat{y}^{(i)}-y^{(i)}), X_2^{(i)} \cdot (\hat{y}^{(i)}-y^{(i)}), ..., X_n^{(i)} \cdot (\hat{y}^{(i)}-y^{(i)}) \right]
\end{align}
\begin{align}
\therefore \nabla_W \text{Loss} = X^{(i)} \cdot (\hat{y}^{(i)}-y^{(i)})
\end{align}


\begin{thebibliography}{2}
\bibitem{DrCoop} Cooper.
Expand Down

0 comments on commit 00fd293

Please sign in to comment.