def update_parameters(parameters, grads, learning_rate):
    """
    update parameters with gradients.

    :param parameters: input parameters, dictionaries
    :param grads: gradients, dictionaries
    :param learning_rate: hyper-parameter alpha for deep learning, floats
    :return: updated parameters, dictionaries
    """

    num_of_layers = len(parameters) // 2  # number of layers in the neural network

    # Update rule for each parameter. Use a for loop.
    for l in range(num_of_layers):
        parameters["W" + str(l + 1)] = parameters["W" + str(l + 1)] - learning_rate * grads["dW" + str(l + 1)]
        parameters["b" + str(l + 1)] = parameters["b" + str(l + 1)] - learning_rate * grads["db" + str(l + 1)]

    return parameters