Posts

Showing posts from July, 2020

5 min Recap for Andrew Ng Deep Learning Specialization-Course 2

Image
Week-1 Building a ML model is an iterative process in which multiple models needs to be tried and tested and then deployed. The first first step is to divide the data-set into 3 parts Train Set Hold-out/Cross Validation Set/Dev Set-It is used to iterate between the models and tuning of hyperparameters. Test Set-It is used to give the unbiased performance of the model. If the data is large then data needs to divided in the ratio of 98%,1% and 1% respectively. Dev and Test set needs to come from same distribution If the model is underfitting the data ,if it contains high error rate then it is said to be Have high bias.If it is overfitting the data ,then it is said to be high variance case. The thumb rule for building a ML model is check if it has- High Bias-then build bigger network or train longer High Variance(dev set performance)-Use More data,Use Regularization Regularization Helps to reduce overfitting and hence high variance. Regularization is done by adding following values- The m

Mini-batch gradient descent vs Momentum vs Adam

Image
5.1 - Mini-batch Gradient descent Run the following code to see how the model does with mini-batch gradient descent. In  [22]: # train 3-layer model layers_dims = [ train_X . shape [ 0 ], 5 , 2 , 1 ] parameters = model ( train_X , train_Y , layers_dims , optimizer = "gd" ) ​ # Predict predictions = predict ( train_X , train_Y , parameters ) ​ # Plot decision boundary plt . title ( "Model with Gradient Descent optimization" ) axes = plt . gca () axes . set_xlim ([ - 1.5 , 2.5 ]) axes . set_ylim ([ - 1 , 1.5 ]) plot_decision_boundary ( lambda x : predict_dec ( parameters , x . T ), train_X , train_Y ) Cost after epoch 0: 0.702405 Cost after epoch 1000: 0.668101 Cost after epoch 2000: 0.635288 Cost after epoch 3000: 0.600491 Cost after epoch 4000: 0.573367 Cost after epoch 5000: 0.551977 Cost after epoch 6000: 0.532370 Cost after epoch 7000: 0.514007 Cost after epoch 8000: 0.496472 Cost after epoch 9000: 0.468014 Accuracy: 0.796666666667 5.2 - Mini-batch gradient