@@ -16,8 +16,8 @@ This project contains several files and directory. A brief description of each i
...
@@ -16,8 +16,8 @@ This project contains several files and directory. A brief description of each i
-`results/`: This folder contains some of the results generated by the program.
-`results/`: This folder contains some of the results generated by the program.
-`knn.py`: Contains functions related to the KNN algorithm.
-`knn.py`: Contains functions related to the KNN algorithm.
-`read_cifar.py`: Contains functions related to reading and parsing the CIFAR-10 dataset.
-`read_cifar.py`: Contains functions related to reading and parsing the CIFAR-10 dataset.
-`nn.py`: Contains functions related to the Neural Network algorithm.
-`mlp.py`: Contains functions related to the Neural Network algorithm.
-`main.ipynb`: Jupyter Notebook containing the main program. It is used to the algorithms and generate the results.
-`main.ipynb`: Jupyter Notebook containing the main program. It is used to test the algorithms and generate the results. It also contains some descriptions regarding the algorithms, notably a mathematical description of the Neural Network algorithm.
## Usage
## Usage
...
@@ -37,3 +37,4 @@ The main program is contained in the `main.ipynb` file. It can be run using Jupy
...
@@ -37,3 +37,4 @@ The main program is contained in the `main.ipynb` file. It can be run using Jupy
## References
## References
- Data Source : The CIFAR-10 Dataset. <https://www.cs.toronto.edu/~kriz/cifar.html>
- Data Source : The CIFAR-10 Dataset. <https://www.cs.toronto.edu/~kriz/cifar.html>
Therefore we find that $\sigma'(x) = \sigma(x) (1 - \sigma(x))$.
#### 2
We use mean squared error as our loss function. We have that
$$
C = \frac{1}{N_{out}} \Sigma_{i=1}^{N_{out}} (\hat{y}_i - y_i)^2
$$
where $N_{out}$ is the number of output neurons, $\hat{y}_i$ is the predicted value of the $i$-th output neuron and $y_i$ is the true value of the $i$-th output neuron (in our case, $y_i = a^{(2)}_i$). We have that
Therefore we find that $\sigma'(x) = \sigma(x) (1 - \sigma(x))$.
#### 2
We use mean squared error as our loss function. We have that
$$
C = \frac{1}{N_{out}} \Sigma_{i=1}^{N_{out}} (\hat{y}_i - y_i)^2
$$
where $N_{out}$ is the number of output neurons, $\hat{y}_i$ is the predicted value of the $i$-th output neuron and $y_i$ is the true value of the $i$-th output neuron (in our case, $y_i = a^{(2)}_i$). We have that
w1 (np.ndarray): The weights of the first layer, of shape (d_in, d_h).
b1 (np.ndarray): The bias of the first layer, of shape (1, d_h).
w2 (np.ndarray): The weights of the second layer, of shape (d_h, d_out).
b2 (np.ndarray): The bias of the second layer, of shape (1, d_out).
data_train (np.ndarray): The data, of shape (N, d_in).
labels_train (np.ndarray): The targets, of shape (N, d_out).
learning_rate (float): The learning rate.
num_epoch (int): The number of epochs.
Returns:
(np.ndarray, np.ndarray, np.ndarray, np.ndarray, list[float]): A tuple containing the resulting weights and biases, and the list of accuracy values of each epoch.