def step_momentum(W, b, dW, db, alpha, v, beta=0.9):
    """Single iteration of gradient descent with momentum.
    NB! In-place modification of 'v'.

    Args:
        W (ndarray[n, 1]):          weights for current step
        b (ndarray[1, 1]):          bias for current step
        dW (ndarray[n, 1]):         weight gradients for current step
        db (ndarray[1, 1]):         bias gradient for current step
        alpha (float):              learning rate
        v (ndarray[1, n]):          moment (exp. weighted average)
        beta (float, optional):     moment decay rate (defaults to 0.9)

    Returns:
        W (ndarray[n, 1]):          updated weights
        b (ndarray[1, 1]):          updated bias
    """
    v[0][...] = beta * v[0] + (1 - beta) * dW
    v[1][...] = beta * v[1] + (1 - beta) * db
    return W - alpha * v[0], b - alpha * v[1]