This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch as t | |
from torch.autograd import grad | |
from scipy.sparse.linalg import LinearOperator, eigsh | |
import numpy as np | |
def get_hessian_eigenvectors(model, loss_fn, train_data_loader, num_batches, device, n_top_vectors, param_extract_fn): | |
""" | |
model: a pytorch model | |
loss_fn: a pytorch loss function | |
train_data_loader: a pytorch data loader |