\documentclass[11pt,a4paper]{article}

% ============================================================
% Packages
% ============================================================
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{amsmath,amssymb}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{enumitem}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{fancyhdr}
\usepackage{titlesec}

% ============================================================
% Page style
% ============================================================
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\small CS3317 Artificial Intelligence}
% >>> CHANGE CW NUMBER HERE <<<
\fancyhead[R]{\small CW2 / CW3 / CW4}
\fancyfoot[C]{\thepage}

\hypersetup{
    colorlinks=true,
    linkcolor=blue!60!black,
    urlcolor=blue!60!black,
    citecolor=blue!60!black,
}

\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\normalsize\bfseries}{\thesubsection}{1em}{}

% ============================================================
% Title block — FILL IN YOUR INFO
% ============================================================
\title{%
    \textbf{CS3317 Artificial Intelligence} \\[6pt]
    \Large Coursework X: Title  % >>> CHANGE HERE <<<
}
\author{
    Name: \underline{\hspace{5cm}} \quad
    Student ID: \underline{\hspace{4cm}}
}
\date{\today}

\begin{document}
\maketitle
\thispagestyle{fancy}

% ============================================================
% INSTRUCTIONS (delete this box before submission)
% ============================================================
\begin{center}
\fbox{\parbox{0.9\textwidth}{
\textbf{Instructions:}
\begin{itemize}[nosep]
    \item Replace ``Coursework X: Title'' with the correct coursework number and title.
    \item Keep only the sections relevant to your coursework (CW2, CW3, or CW4).
    \item Delete the sections for the other two courseworks.
    \item Delete this instruction box before submission.
    \item Recommended page limit: 6--10 pages (excluding appendix).
\end{itemize}
}}
\end{center}

% ************************************************************
%   CW2 SECTIONS — Logistic Regression
%   (Delete if submitting CW3 or CW4)
% ************************************************************

\section{Implementation Overview}

Briefly describe your implementations of:
\begin{itemize}
    \item Softmax function (numerical stability considerations)
    \item Each loss function: cross-entropy, hinge, exponential, squared
    \item Gradient descent optimizer
\end{itemize}

\section{Loss Function Comparison}

\subsection{Training Curves}

Include the comparison plot generated by \texttt{python run.py --compare\_all}.

\begin{figure}[h]
    \centering
    % \includegraphics[width=0.95\textwidth]{outputs/loss_comparison.png}
    \caption{Training loss and validation accuracy curves for all four loss functions.}
    \label{fig:cw2-loss-comparison}
\end{figure}

\subsection{Results Summary}

\begin{table}[h]
\centering
\caption{Test accuracy and convergence comparison across loss functions.}
\label{tab:cw2-results}
\begin{tabular}{lccc}
\toprule
\textbf{Loss Function} & \textbf{Test Accuracy} & \textbf{Convergence Speed} & \textbf{Stability} \\
\midrule
Cross-Entropy &  &  &  \\
Hinge         &  &  &  \\
Exponential   &  &  &  \\
Squared       &  &  &  \\
\bottomrule
\end{tabular}
\end{table}

\subsection{Analysis}

\begin{itemize}
    \item Which loss function achieves the best test accuracy? Why?
    \item Which loss function converges fastest? Why?
    \item Which loss function is most/least stable during training?
    \item What mathematical properties explain the different behaviors?
\end{itemize}

\section{Visualization}

\subsection{Learned Weight Templates}

\begin{figure}[h]
    \centering
    % \includegraphics[width=0.8\textwidth]{outputs/cross_entropy/weight_visualization.png}
    \caption{Learned weight templates for each class (cross-entropy).}
    \label{fig:cw2-weights}
\end{figure}

Discuss what visual patterns the model has learned for each class.

\subsection{Confusion Matrix}

\begin{figure}[h]
    \centering
    % \includegraphics[width=0.6\textwidth]{outputs/cross_entropy/confusion_matrix.png}
    \caption{Confusion matrix on the test set (cross-entropy).}
    \label{fig:cw2-cm}
\end{figure}

Discuss which classes are most frequently confused and why.

\section{Bonus (Optional)}

Describe any bonus features you implemented (L2 regularization, learning rate schedule, etc.) and their effect on performance.

\section{Conclusion}

Summarize your key findings from this coursework.

% ************************************************************
%   CW3 SECTIONS — MLP & Backpropagation
%   (Delete if submitting CW2 or CW4)
% ************************************************************

% \section{Implementation Overview}
%
% Briefly describe your implementations:
% \begin{itemize}
%     \item Layer forward/backward (Linear, ReLU, Sigmoid)
%     \item How you reused CW2 code (softmax, cross-entropy, gradient computation)
%     \item MLP assembly and backpropagation chain
%     \item SGD with momentum
% \end{itemize}
%
% \section{Hyperparameter Exploration}
%
% \subsection{Hidden Layer Dimension}
%
% Experiment with different hidden layer widths (e.g., 32, 64, 128, 256, 512).
%
% \begin{table}[h]
% \centering
% \caption{Effect of hidden layer dimension on performance.}
% \begin{tabular}{lcccc}
% \toprule
% \textbf{Hidden Dim} & \textbf{Train Acc} & \textbf{Val Acc} & \textbf{Test Acc} & \textbf{\#Params} \\
% \midrule
%  &  &  &  &  \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \begin{figure}[h]
%     \centering
%     % \includegraphics[width=0.7\textwidth]{outputs/sweep_hidden_dim.png}
%     \caption{Accuracy vs.\ hidden layer dimension.}
% \end{figure}
%
% \textbf{Analysis:} How does width affect performance? Is there a diminishing return?
%
% \subsection{Number of Layers}
%
% Experiment with different depths (e.g., 1, 2, 3, 4 hidden layers).
%
% \begin{table}[h]
% \centering
% \caption{Effect of network depth on performance.}
% \begin{tabular}{lcccc}
% \toprule
% \textbf{Num Layers} & \textbf{Train Acc} & \textbf{Val Acc} & \textbf{Test Acc} & \textbf{\#Params} \\
% \midrule
%  &  &  &  &  \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \textbf{Analysis:} Does deeper always mean better? What issues arise with depth?
%
% \subsection{Learning Rate}
%
% Experiment with different learning rates (e.g., 0.001, 0.005, 0.01, 0.05, 0.1).
%
% \textbf{Analysis:} What happens with too high/low learning rates?
%
% \subsection{Additional Experiments (Optional)}
%
% Explore other hyperparameters: momentum, activation function (ReLU vs.\ Sigmoid), batch size, etc.
%
% \section{Comparison with CW2}
%
% \begin{table}[h]
% \centering
% \caption{Comparison between logistic regression (CW2) and MLP (CW3).}
% \begin{tabular}{lccc}
% \toprule
% \textbf{Method} & \textbf{Test Accuracy} & \textbf{\#Parameters} \\
% \midrule
% Logistic Regression (CW2) &  & 7,850 \\
% MLP [128, 64] (CW3)       &  &  \\
% Best MLP (CW3)             &  &  \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \textbf{Discussion:}
% \begin{itemize}
%     \item Why does the MLP outperform logistic regression?
%     \item What is the role of non-linear activation functions?
%     \item How does the MLP capture more complex patterns?
% \end{itemize}
%
% \section{Bonus (Optional)}
%
% Describe any bonus features (Adam optimizer, dropout, etc.).
%
% \section{Conclusion}
%
% Summarize your key findings about MLP hyperparameters and the advantage of multi-layer networks.

% ************************************************************
%   CW4 SECTIONS — CNN with PyTorch
%   (Delete if submitting CW2 or CW3)
% ************************************************************

% \section{CNN Architecture}
%
% \subsection{SimpleCNN}
%
% Describe your SimpleCNN architecture in detail.
%
% \begin{verbatim}
% Layer-by-layer breakdown:
% (fill in your architecture here)
% \end{verbatim}
%
% \textbf{Total parameters:} \_\_\_\_\_\_\_\_
%
% \textbf{Design choices:} Why did you choose this architecture?
%
% \subsection{Training Results}
%
% \begin{figure}[h]
%     \centering
%     % \includegraphics[width=0.95\textwidth]{outputs/simple_cnn/training_summary.png}
%     \caption{SimpleCNN training summary.}
% \end{figure}
%
% \begin{table}[h]
% \centering
% \caption{SimpleCNN results.}
% \begin{tabular}{lc}
% \toprule
% \textbf{Metric} & \textbf{Value} \\
% \midrule
% Best Val Accuracy &  \\
% Test Accuracy     &  \\
% Training Time     &  \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \section{Hyperparameter Exploration}
%
% Explore at least 2 of: optimizer choice, learning rate, architecture variations, data augmentation.
%
% \section{Data Augmentation}
%
% \begin{table}[h]
% \centering
% \begin{tabular}{lc}
% \toprule
% \textbf{Setting} & \textbf{Test Accuracy} \\
% \midrule
% No augmentation   &  \\
% With augmentation  &  \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% What augmentation transforms did you use? How did they help?
%
% \section{DeepCNN (Bonus)}
%
% Describe your DeepCNN architecture and any advanced techniques used.
%
% \section{Cross-Coursework Comparison}
%
% \begin{table}[h]
% \centering
% \caption{Performance comparison across all courseworks.}
% \begin{tabular}{llcc}
% \toprule
% \textbf{Method} & \textbf{CW} & \textbf{Test Accuracy} & \textbf{\#Parameters} \\
% \midrule
% Logistic Regression & CW2 &  & 7,850 \\
% MLP [128, 64]       & CW3 &  &  \\
% SimpleCNN           & CW4 &  &  \\
% DeepCNN (bonus)     & CW4 &  &  \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \textbf{Discussion:}
% \begin{itemize}
%     \item Why does CNN outperform MLP on image data?
%     \item What is the role of convolutional layers in capturing spatial patterns?
%     \item How does parameter sharing in CNNs compare to fully connected layers?
%     \item What did you learn from the progression: linear models $\to$ MLP $\to$ CNN?
% \end{itemize}
%
% \section{Conclusion}
%
% Summarize your key findings across all three courseworks.

\end{document}
