import numpy as np
import matplotlib.pyplot as plt
import h5py # 用于与存储在H5文件中的数据集交互
# scipy和PIL 用于最后用你自己的图片测试你的模型
import scipy
from PIL import Image
from scipy import ndimage
from lr_utils import load_dataset #该函数在lr_utils.py文件中
train_set_x_orig , train_set_y , test_set_x_orig , test_set_y , classes = load_dataset()
m_train = train_set_y.shape[1] #训练集图片数量
m_test = test_set_y.shape[1] #测试集图片数量
m_train = train_set_y.shape[1] #训练集里图片的数量。
m_test = test_set_y.shape[1] #测试集里图片的数量。
num_px = train_set_x_orig.shape[1] #训练、测试集里面的图片的宽度和高度(均为64x64)。
#变换维度,每张图片的信息集中在一列上
train_set_x_flatten = train_set_x_orig.reshape(train_set_x_orig.shape[0],-1).T
test_set_x_flatten = test_set_x_orig.reshape(test_set_x_orig.shape[0],-1).T
#把颜色通道映射到[0,1]去
train_set_x = train_set_x_flatten / 255
test_set_x = test_set_x_flatten / 255
def sigmoid(z):#映射到[0,1]概率的函数
return 1/(1+np.exp(-z))
def init_forwb(dim):
#作用是
吴恩达<深度学习>第二周编程作业 详细注解
最新推荐文章于 2024-04-12 23:18:40 发布