72 min total

Computer Vision & OpenCV

Convolutional networks and training

Convolutional networks and training
Bias–variance tradeoff

Variance: how much models predictions vary when its trained on different subsets training data, error is introduced because model is too sensitive to fluctuations in training data, high variance can lead to overfitting

Bias is error introduced by simplifying assumptions in a model; high bias can prevent it from capturing the underlying relationship.

Under suitable activation assumptions, a sufficiently wide single-hidden-layer network can approximate continuous functions on compact domains. This is an approximation result, not a guarantee that training will find a good model or that it will generalize.

Convolutional Neural Network: If you use FNNs to input 100x100 image → millions of parameters, lead to overfitting on training dataset. In images, patterns like edges, shapes appear in multiple locations a FNN would have to relearn the same pattern for every location which is wasteful. Convolution applies a filter across an image, allows model to detect local features across different regions reducing the number of parameters

Convolutional input, filters, and output dimensions
A convolutional receptive field spanning RGB channels

If images are multichannel, filters would be multichannel too.

Neurons on a surface level have local connectivity (connected to a small region of input image) but are depth wise global (connected to each channel value)

Local connectivity: neuron is connected to small, local region of the input, not the entire input

Spatial connectivity: how neighboring pixels in image are connected helps identify shapes, edges

Receptive field: region of the input image that affects output neuron

Depth map: represents distance from camera, used in 3D vision

Pooling: down sampling technique to reduce spatial size of feature maps

Max pooling with a two-by-two filter and stride two
  • Makes model faster
  • Adds spatial invariance
  • Allows us to observe large receptive field

Pooling can reduce model size and overfitting risk, but does not guarantee generalization.

AlexNet architecture and feature-map dimensions

Explainability for CNNs ~ trying to explain what internal layers are learning

Features learned at successive CNN layers

Choosing Hyper parameters

Split data into training, validation, and test sets. Fit model parameters on training data, choose hyperparameters using validation data, and reserve the test set for the final evaluation. Selecting hyperparameters directly on the test set makes its result optimistic.

Three approaches to choosing hyperparameters and splitting training, validation, and test data
ApproachWhat is selected/evaluatedProblem or benefit
Use all dataChoose hyperparameters on the same data used to fit the networkA large network can fit training examples; this does not estimate generalization.
Train/test only, tune on testFit on training data and choose settings by test performanceThe test data influences selection, so it no longer provides an independent final estimate.
Train/validation/testFit weights on train, choose settings on validation, evaluate once on testSeparates fitting, model selection, and final evaluation.

Saddle points have zero gradient but are neither local minima nor maxima. Flat regions and poor conditioning can slow optimization.

Anisotropic loss surfaces: loss changes fast in one direction, slow in another

SGD equation:

  • Faster updates ⊖ Unstable training ⊖ Can stuck in saddle points or local minima
SGD and momentum trajectories on an elongated loss surface

Jittery updates due to large change in y and small change in x

Our gradients come from minibatches so they can be noisy

Hessian matrix has a high condition number

SGD+Momentum: If gradients keep pointing in the same direction, inertia increases

SGD with momentum is just running mean of gradients

Momentum and gradient vectors combine into an update

Adam (Adaptive Moment Estimation): combines momentum and RMSProp

Data Augmentation: since neurons on a surface level have local connectivity and neurons may memorize biases(e.g. orientational). Augmentation increases dataset and generalizes model for real-world variations.

  • Horizontal/Vertical Flips
  • Random Crops and Zoom
  • Randomized contrast/brightness
  • Random Translations
  • Noise injection
  • Random Cutouts to prevent occlusion
  • Random Warp
  • Reducing number of Color bits