Convolutional Neural Networks (CNNs)

Convolutional Neural Networks, MIT 6.S191 Alexander Amini - Convolutional Neural Networks, MIT 6.S191 (2020)

Convolutional Neural Networks, Stanford University Serena Yeung - Convolutional Neural Networks, Stanford University (2017)

CNN Architectures, Stanford University Serena Yeung - CNN Architectures, Stanford University (2017)

CNN Implementation

import numpy_neural_network as npnn
import npnn_datasets

model = npnn.Sequential()
model.layers = [
  npnn.Conv2D(shape_in=(8, 8, 1), shape_out=(6, 6, 4), kernel_size=3, stride=1),
  npnn.LeakyReLU(6 * 6 * 4),

  npnn.MaxPool(shape_in=(6, 6, 4), shape_out=(3, 3, 4), kernel_size=2),
  npnn.Pad2D(shape_in=(3, 3, 4), pad_axis0=1, pad_axis1=1),
  npnn.Conv2D(shape_in=(5, 5, 4), shape_out=(3, 3, 4), kernel_size=3, stride=1),
  npnn.LeakyReLU(3 * 3 * 4),

  npnn.AvgPool(shape_in=(3, 3, 4), shape_out=(1, 1, 4), kernel_size=3),
  npnn.Reshape(shape_in=(1, 1, 4), shape_out=(4)),
  npnn.Softmax(4)
]

loss_layer = npnn.loss_layer.CrossEntropyLoss(4)
optimizer  = npnn.optimizer.Adam(alpha=1e-2)
dataset    = npnn_datasets.FourSteppedIcons()

optimizer.norm  = dataset.norm
optimizer.model = model
optimizer.model.chain = loss_layer

Four Different Icon Pattern Classification using a CNN

Four Different Icon Pattern Classification using a CNN
plot of network validation batch data target values (green) and predicted network output values (orange)

References

A Beginner’s Guide to Convolutional Neural Networks Convolutional Neural Networks - A Beginner’s Guide