Plot_decision_boundary ( lambda x : predict (parameters, x. mean (y_pred = Y ) print (accuracy ) def plot_decision_boundary (model, X, y ) : Predictions = A2 > 0.5 return predictionsĪccuracy = np. Parameters = nn_model (X, Y, n_h = 3, num_iterations = 10000, print_cost = True ) def predict (parameters, X ) :Ī2, cache = forward_propagation (X, parameters ) append (cost ) # 每隔 1000 次训练,打印 cost if print_cost and i % 1000 = 0 : print ( "Cost after iteration %i: %f" % (i, cost ) ) return parameters Parameters = update_parameters (parameters, grads ) # 更新权重 Grads = backward_propagation (parameters, cache, X, Y ) # 反向传播 J = # 存储损失函数 for i in range ( 0, num_iterations ) :Ī2, cache = forward_propagation (X, parameters ) # 正向传播Ĭost = compute_cost (A2, Y, parameters ) # 计算损失函数 scatter (X, X, c =Y, s = 40, cmap =plt.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |