Skip to content

Instantly share code, notes, and snippets.

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