目的:搭建一层隐藏层的浅层神经网络
【准备】
1.导入相关包
import xxxx
2.加载数据集
X, Y = load_planar_dataset()
3.查看数据
plt.scatter(X[0, :], X[1, :], c=Y, s=40, cmap=plt.cm.Spectral);
[image]
4.查看数据集dim
shape_X = X.shape
shape_Y = Y.shape
m = X.shape[1] # training set size
【构建算法模型】
1.定义基本模型
def layer_sizes(X, Y):
n_x = X.shape[0] # 定义输入层size
n_h = 4 #定义隐藏层size
n_y = Y.shape[0] # 定义输出层size
2.初始化参数
def initialize_parameters(n_x, n_h, n_y):
W1 = np.random.randn(n_h, n_x)*0.01
b1 =