The first building blocks are data representation, activation functions, and the gradients used during training. m denotes the number of training examples. Sigmoid saturation For a very positive or negative value, gradient flats out in sigmoid Results in very small gradients Makes training very slow during gradient descent Why deep learning became practical More Data More Computation Better Algorithms Feature vector: representation of data into numerical format that can be processed by ML algorithms Notation used below: Logistic regression & vectorization — diagram The feature vector x has nₓ components: x ∈ ℝⁿˣ. Logistic regression Logistic regression & vectorization — diagram Logistic regression & vectorization — diagram Broadcasting Broadcasting is a technique that allows NumPy to perform element-wise operations on arrays of different shapes by automatically expanding their dimensions to match. np.dot(a, b) performs a matrix multiplication on a and 𝑏, whereas 𝑎∗𝑏 performs an element-wise multiplication. Logistic regression & vectorization — diagram Matrix multiplication Logistic regression & vectorization — diagram Element-wise multiplication Logistic regression & vectorization — diagram a_i^{[l]}\quad\text{is the activation of neuron }i\text{ in layer }l Hidden layers & activations — diagram Activation functions Hidden layers & activations — diagram Hidden layers & activations — diagram Layer notation and matrix dimensions Forward pass & backpropagation — diagram Forward pass & backpropagation — diagram Matrix dimensions Forward pass & backpropagation — diagram Forward pass & backpropagation — diagram Why use multiple hidden layers? Then the single layer would have to be exponentially long to fit all possibilities Forward pass & backpropagation — diagram Forward and backward functions Forward pass & backpropagation — diagram Parameters and hyperparameters Forward pass & backpropagation — diagram Random initialization Breaking Symmetry: Random initialization of weights ensures that each neuron computes a different function, breaking the symmetry. This allows the network to learn from the error and make individual updates to each neuron. Accelerates Learning: Initializing weights to small random values ensures that the activation functions operate in ranges where their gradients are not extremely small, which helps speed up the learning process. Once the network can learn, the next questions are how to keep it from overfitting and how to make training behave reliably. Training, development, and test sets Machine learning is a highly iterative process Make sure that the Train & dev/test data distributions are the same For meaningful evaluations Use dev set to evaluate and iterate models performance Test set is only used to provide unbiased estimate of final model performance Regularization Used to prevent overfitting in machine learning models \text{L1 penalty}=\frac{\lambda}{2m}\sum_j |w_j| \text{L2 penalty}=\frac{\lambda}{2m}\sum_j w_j^2 L2 Norm is also called Euclidean norm/Frobenius norm L2 regularization is also called 'weight decay' L1 regularization adds absolute values of weight parameters, leading to many sparse(zero) weight vectors Weight decay multiplies weights by value slightly less than one during each GD iteration L2/Frobenius Norm: Regularization & dropout — diagram New Backprop eq: Regularization & dropout — diagram Regularization & dropout — diagram Regularization & dropout — diagram Regularization & dropout — diagram Dropout regularization Regularization & dropout — diagram During training, dropout temporarily deactivates randomly selected units, so each pass uses a different subset of the network. Dropout in neural networks mimics ensemble learning by training different subsets of nodes in each iteration. During testing, without dropout, it's like averaging outputs from all these subnetworks. This approach mirrors ensemble methods, where multiple models' outputs are combined for improved robustness. Essentially, dropout acts as an efficient way to train numerous networks sharing the same weights, providing ensemble-like benefits within a single network structure. Inverted dropout Illustrating with layer3 and Keep_prob = 0.8 keep_prob = 0.8 D3 = np.random.rand(*A3.shape) < keep_prob A3 = A3 * D3 / keep_prob Net activations during inference would be larger if we don’t use inverted dropout technique. Regularization & dropout — diagram In normal dropout algorithm, during inference activations are multiplied by p to ensure that activations are not too high Inverted dropout divides retained activations by keep_prob during training to preserve their expected scale. No dropout scaling is needed during inference. Dropout has similar effect to L2 regularization We can apply dropout to input layers aswell as set individual keep_probs for different layers to ensure that layers with high params are dropout more Other regularization methods Data augmentation Early stopping Regularization &…