{"id":17086266,"url":"https://github.com/kach/jax.value_and_jacfwd","last_synced_at":"2025-10-07T01:12:08.674Z","repository":{"id":66653304,"uuid":"442205056","full_name":"kach/jax.value_and_jacfwd","owner":"kach","description":"Provides an implementation of a missing primitive in JAX, value_and_jacfwd","archived":false,"fork":false,"pushed_at":"2021-12-27T16:11:11.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-28T20:41:29.050Z","etag":null,"topics":["automatic-differentiation","jax"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kach.png","metadata":{"files":{"readme":"README.txt","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-12-27T16:01:38.000Z","updated_at":"2021-12-27T16:12:39.000Z","dependencies_parsed_at":"2023-02-28T16:30:34.437Z","dependency_job_id":null,"html_url":"https://github.com/kach/jax.value_and_jacfwd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Fjax.value_and_jacfwd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Fjax.value_and_jacfwd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Fjax.value_and_jacfwd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kach%2Fjax.value_and_jacfwd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kach","download_url":"https://codeload.github.com/kach/jax.value_and_jacfwd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245115332,"owners_count":20563138,"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":["automatic-differentiation","jax"],"created_at":"2024-10-14T13:28:05.486Z","updated_at":"2025-10-07T01:12:03.607Z","avatar_url":"https://github.com/kach.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"value_and_jacfwd.py\nCopyright (c) 2021 Kartik Chandra; see MIT license attached\n\nThis patch adds a function jax.value_and_jacfwd, which is the\nforward-mode version of jax.value_and_grad. It allows returning\nthe value of a function in addition to its derivative, so that\nyou don't need to evaluate the function twice to get both the\nvalue and its derivative as you would using plain jax.jacfwd.\nFor example:\n\n\u003e\u003e\u003e import jax, value_and_jacfwd\n\u003e\u003e\u003e def g(x):\n\u003e\u003e\u003e     return (x ** 2).sum()\n\u003e\u003e\u003e dg = jax.value_and_jacfwd(g, has_aux=False)\n\u003e\u003e\u003e y, dg = dg(np.arange(3) * 1.)\n\u003e\u003e\u003e print(f'g(x) = {y}')\ng(x) = 5.0\n\u003e\u003e\u003e print(f'dg(x) = {dg}')\ndg(x) = [0. 2. 4.]\n\nYou can also export auxiliary values using the has_aux=True parameter,\nagain by analogy to jax.value_and_grad. For example:\n\n\u003e\u003e\u003e import jax, value_and_jacfwd\n\u003e\u003e\u003e def f(x):\n\u003e\u003e\u003e     return (x ** 2).sum(), x.sum()\n\u003e\u003e\u003e df = jax.value_and_jacfwd(f, has_aux=True)\n\u003e\u003e\u003e (y, aux), df = df(np.arange(3) * 1.)\n\u003e\u003e\u003e print(f'f(x) = {y}')\nf(x) = 5.0\n\u003e\u003e\u003e print(f'df(x) = {df}')\ndf(x) = [0. 2. 4.]\n\u003e\u003e\u003e print(f'aux = {aux}')\naux = 3.0\n\nThis patch addresses the following Github issue:\n  https://github.com/google/jax/pull/762\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkach%2Fjax.value_and_jacfwd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkach%2Fjax.value_and_jacfwd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkach%2Fjax.value_and_jacfwd/lists"}