Chapter 1 Intro

This is a write-up of iRisk’s Spring 2024 project: Neural Nets from Scratch


The organization is:

  1. Single-Layer NN Notes
    • intro notation & methodology for single-hidden layer neural network
  2. Digit Model
    • GLMs on MNIST handwritten digits as an application intro
  3. Multi-Layer NN Notes
    • intro notation & methodology for multi-hidden layer neural network
  4. Multi-Layer NN Model
    • implementation of multi-layer neural network in R

1.0.1 Setup

knitr::opts_chunk$set(echo = TRUE)
set.seed(50)
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.1
## Warning: package 'readr' was built under R version 4.3.1
## Warning: package 'forcats' was built under R version 4.3.1
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.2     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(keras)
## Warning: package 'keras' was built under R version 4.3.2
library(glmnet)
## Warning: package 'glmnet' was built under R version 4.3.2
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.3.2
## 
## Attaching package: 'Matrix'
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## Loaded glmnet 4.1-8