练习:Planar data classification with a hidden layer

 b2 = np.zeros((1,1))     #用于输出1*1维的全部值是0的矩阵
W2 = np.random.randn(4,4) #生成随机4*4的矩阵,取值为正太分布随机样本
predictions = np.where(A2 > 0.5, 1, 0)

every time I intend to apply a if/else action with two possible outcomes into a data structure (i.e. in that case, vector A2) I use the function np.where( condition, outcome1, outcome2). outcome1 is applied when condition is true, otherwise outcome2 applies.

你可能感兴趣的:(python学习)