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
def compute_hessian_spectrum(model, feature_model, data_loader, loss_fn, num_eigenthings=20, max_iter=10, tol=1e-6, output_dir=None): | |
""" | |
Compute the top eigenvalues of the Hessian matrix using the Lanczos algorithm. | |
Args: | |
model: The model to compute Hessian spectrum for (linear classifier) | |
feature_model: The feature extraction model | |
data_loader: DataLoader providing input data | |
loss_fn: Loss function |