Пример #1
0
 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
Пример #2
0
def test_interface_ggnmp_conv():
    interface_test(new_ext.PCHMP(), use_conv=True)
Пример #3
0
def test_interface_ggnmp():
    interface_test(new_ext.PCHMP())
Пример #4
0
            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))