{"id":13717362,"url":"https://github.com/mariogeiger/hessian","last_synced_at":"2026-03-16T04:38:45.706Z","repository":{"id":76833487,"uuid":"117135522","full_name":"mariogeiger/hessian","owner":"mariogeiger","description":"hessian in pytorch","archived":false,"fork":false,"pushed_at":"2020-10-27T07:57:11.000Z","size":27,"stargazers_count":187,"open_issues_count":0,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-01T23:13:05.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mariogeiger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-11T18:12:18.000Z","updated_at":"2025-03-18T03:33:27.000Z","dependencies_parsed_at":"2023-03-01T17:30:24.849Z","dependency_job_id":null,"html_url":"https://github.com/mariogeiger/hessian","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mariogeiger/hessian","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariogeiger%2Fhessian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariogeiger%2Fhessian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariogeiger%2Fhessian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariogeiger%2Fhessian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mariogeiger","download_url":"https://codeload.github.com/mariogeiger/hessian/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariogeiger%2Fhessian/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265195484,"owners_count":23726105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T00:01:21.222Z","updated_at":"2026-03-16T04:38:40.648Z","avatar_url":"https://github.com/mariogeiger.png","language":"Python","funding_links":[],"categories":["Pytorch \u0026 related libraries｜Pytorch \u0026 相关库","Pytorch \u0026 related libraries"],"sub_categories":["Other libraries｜其他库:","Other libraries:"],"readme":"# hessian\n\nInstall with\n```\npython -m pip install git+https://github.com/mariogeiger/hessian.git\n```\n\n## Compute Hessian\n```python\nimport torch\nfrom hessian import hessian\n\nx = torch.tensor([1.5, 2.5], requires_grad=True)\nh = hessian(x.pow(2).prod(), x, create_graph=True)\n\nprint(h)\n# tensor([[12.5, 15],\n#         [15,  4.5]], grad_fn=\u003cCopySlices\u003e)\n\nh2 = hessian(h.sum(), x)\nprint(h2)\n# tensor([[4, 8],\n#         [8, 4]])\n```\n\nThe hessian is computed naively assuming the commutativity of the derivatives.\n\n## Compute Jacobian\n```python\nimport torch\nfrom hessian import jacobian\n\nx = torch.tensor([1.5, 2.5], requires_grad=True)\ny = torch.tensor([5.5, -4.], requires_grad=True)\nj = jacobian(x.pow(y), [x, y])\n\nprint(j)\n# tensor([[34.1, -0.00,  3.77,  0.00],\n#         [ 0.0, -0.04,  0.00,  0.02]])\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariogeiger%2Fhessian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariogeiger%2Fhessian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariogeiger%2Fhessian/lists"}