def model(X_train, Y_train, X_test, Y_test, num_iterations=2000, learning_rate=0.5, print_cost=False): w, b = inicializarconcero(X_train.shape[0]) parameters, grads, costs = optimizar(w, b, X_train, Y_train, num_iterations, learning_rate, print_cost) w = parameters["w"] b = parameters["b"] Y_prediction_test = predict4(w, b, X_test) Y_prediction_train = predict4(w, b, X_train) d = { "costos": costs, "Y_pred_test": Y_prediction_test, "Y_pred_variable": Y_prediction_train, "w": w, "b": b, "learning_rate": learning_rate, "cantidad_iteraciones": num_iterations } return d
dim = 2 w, b = inicializarconcero(dim) print("w = " + str(w)) print("b = " + str(b)) w, b, X, y = np.array([[1], [2]]), 2, np.array([[1, 2], [3, 4]]), np.array([[1, 0]]) grads, cost = propagate2(w, b, X, y) print("dw = " + str(grads["dw"])) print("db = " + str(grads["db"])) print("cost = " + str(cost)) print("-----------------------------------") params, grads, costs = optimizar(w, b, X, y, num_iterations=10, learning_rate=0.009, print_costo=False) print("w = " + str(params["w"])) print("b = " + str(params["b"])) print("dw = " + str(grads["dw"])) print("db = " + str(grads["db"])) print("-----------------------------------") print("predictions = " + str(predict4(w, b, X))) def gradiente_aprendisaje(X, y, dimensiones, curvaaprendisaje=0.01,