def get_weights(model):
    """
    Given a model, return a vector of weights.
    """
    x0 = None
    for p in model.parameters():
        if x0 is None:
            x0 = p.data.view(-1)
        else:
            x0 = torch.cat((x0, p.data.view(-1)))
    return x0.cpu().numpy()

    Given a model, return a vector of weights.
    
grok/measure.py