Logistic Regression with a Neural Network mindset
Welcome to your first (required) programming assignment! You will build a logistic regression classifier to recognize cats. This assignment will step you through how to do this with a Neural Network mindset, and so will also hone your intuitions about deep learning.
Instructions:
- Do not use loops (for/while) in your code, unless the instructions explicitly ask you to do so.
You will learn to:
- Build the general architecture of a learning algorithm, including:
- Initializing parameters
- Calculating the cost function and its gradient
- Using an optimization algorithm (gradient descent)
- Gather all three functions above into a main model function, in the right order.
这边的主要任务就是构建一个logistics回归的二分分类器去分类猫,主要分为如下几步:
1)导入所需要的package,对data进行preprocessing
2)编写必要的Basic function,比如sigmoid、initialize_with_zeros等等
3)最后构建model,测试
下面详细展开:
1.数据的导入以及预处理
import numpy as np
import matplotlib.pyplot as plt
import h5py
import scipy
from PIL import Image
from scipy import ndimage
from lr_utils import load_dataset
# Loading the data (cat/non-cat)
train_set_x_orig, train_set_y, tes