def vector_to_dictionary(param_vec, layer_dims):
    """

    :param param_vec: -- a vector contains "Wi" and "bi", flatted parameter
    :param layer_dims: -- a list contains [n0,n1,n2,...,nL]
    :return:
    :parameter -- a dictionary contains "Wl" and "bl"
    """
    L = len(layer_dims)
    parameter = dict()
    index_W, index_b = 0, 0
    for l in range(1, L):
        parameter["W"+str(l)] = param_vec[index_W:index_W + layer_dims[l]*layer_dims[l-1]].reshape(layer_dims[l], layer_dims[l-1])
        index_b = index_W + layer_dims[l]*layer_dims[l-1]
        parameter["b"+str(l)] = param_vec[index_b:index_b + layer_dims[l]].reshape(layer_dims[l],1)
        index_W = index_b + layer_dims[l]
    return parameter