def get_params(model, recurse=False):
    """Returns dictionary of paramters

    Arguments:
        model {torch.nn.Module} -- Network to extract the parameters from

    Keyword Arguments:
        recurse {bool} -- Whether to recurse through children modules

    Returns:
        Dict(str:numpy.ndarray) -- Dictionary of named parameters their
                                   associated parameter arrays
    """
    params = {k: v.detach().cpu().numpy().copy()
              for k, v in model.named_parameters(recurse=recurse)}
    # torch.nn.utils.prune renames weight/bias param weight_orig/bias_orig
    # and creates weight/bias attribute instead for pruned weights
    pnames = list(params.keys())
    for pname in pnames:
        if pname.endswith("_orig"):
            params.pop(pname)
            params[pname[:-5]] = getattr(model, pname[:-5]).detach().cpu().numpy().copy()

    return params