def pchmp(self, mat_list, modify): assert len(mat_list) == len(list(self.model.parameters())) results = [] with backpack(new_ext.PCHMP(modify=modify)): self.loss().backward() for p, mat in zip(self.model.parameters(), mat_list): results.append(p.pchmp(mat)) return results
def test_interface_ggnmp_conv(): interface_test(new_ext.PCHMP(), use_conv=True)
def test_interface_ggnmp(): interface_test(new_ext.PCHMP())
model.parameters(), extension, lr=LR, damping=DAMPING, maxiter=CG_MAX_ITER, tol=CG_TOL, atol=CG_ATOL, ) return optimizer_fn curvatures = [ extensions.GGNMP(), extensions.HMP(), extensions.PCHMP(modify="abs"), extensions.PCHMP(modify="clip"), ] labels = [ "GGN", "Hessian", "PCH-abs", "PCH-clip", ] optimizers = [] for curvature in curvatures: optimizers.append(make_cgn_optimizer_fn(curvature))