{"id":20507360,"url":"https://github.com/hahnec/torchimize","last_synced_at":"2025-04-08T03:10:25.533Z","repository":{"id":46545518,"uuid":"472262430","full_name":"hahnec/torchimize","owner":"hahnec","description":"numerical optimization in pytorch","archived":false,"fork":false,"pushed_at":"2024-05-20T08:32:47.000Z","size":21345,"stargazers_count":137,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T16:21:25.533Z","etag":null,"topics":["gauss-newton","gauss-newton-method","gradient-descent","levenberg-marquardt","levenberg-marquardt-algorithm","parallel","parallel-computing","pytorch"],"latest_commit_sha":null,"homepage":"https://hahnec.github.io/torchimize/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hahnec.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-03-21T09:12:26.000Z","updated_at":"2025-03-25T16:33:15.000Z","dependencies_parsed_at":"2023-12-20T12:08:14.906Z","dependency_job_id":"80239003-c144-459e-8488-74dee8bc1672","html_url":"https://github.com/hahnec/torchimize","commit_stats":{"total_commits":229,"total_committers":5,"mean_commits":45.8,"dds":0.03056768558951961,"last_synced_commit":"e42d85fe3a181cd3a7b0e04d32a8e0a62a221db3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hahnec%2Ftorchimize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hahnec%2Ftorchimize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hahnec%2Ftorchimize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hahnec%2Ftorchimize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hahnec","download_url":"https://codeload.github.com/hahnec/torchimize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767236,"owners_count":20992548,"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":["gauss-newton","gauss-newton-method","gradient-descent","levenberg-marquardt","levenberg-marquardt-algorithm","parallel","parallel-computing","pytorch"],"created_at":"2024-11-15T20:13:39.463Z","updated_at":"2025-04-08T03:10:25.500Z","avatar_url":"https://github.com/hahnec.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"|logo|\n\n..\n\nDescription\n===========\n\n*torchimize* contains implementations of the Gradient Descent, Gauss-Newton and Levenberg-Marquardt optimization algorithms using the PyTorch library. The main motivation for this project is to enable convex optimization on GPUs based on the torch.Tensor class, which (as of 2022) is widely used in the deep learning field. This package features the capability to minimize several least-squares optimization problems at each loop iteration in parallel.\n\n|coverage| |tests_develop| |tests_master| |pypi| |license|\n\nInstallation\n============\n\n``$ python3 -m pip install torchimize``\n\nKick-Start\n==========\n\nSingle Cost Optimization\n------------------------\n\n.. code-block:: python\n\n    # single gradient descent\n    from torchimize.functions.single.gda_fun_single import gradient_descent\n    coeffs_list = gradient_descent(initials, cost_fun, args=(other_args,))\n\n    # single gauss-newton\n    from torchimize.functions import lsq_gna\n    coeffs_list = lsq_gna(initials, cost_fun, args=(other_args,))\n\n    # single levenberg-marquardt\n    from torchimize.functions import lsq_lma\n    coeffs_list = lsq_lma(initials, function=cost_fun, jac_function=jac_fun, args=(other_args,))\n\nParallel Cost Optimization\n--------------------------\n\n.. code-block:: python\n\n    # parallel gradient descent for several optimization problems at multiple costs\n    from torchimize.functions import gradient_descent_parallel\n    coeffs_list = gradient_descent_parallel(\n                        p = initials_batch,\n                        function = multi_cost_fun_batch,\n                        jac_function = multi_jac_fun_batch,\n                        args = (other_args,),\n                        wvec = torch.ones(5, device='cuda', dtype=initials_batch.dtype),\n                        ftol = 1e-8,\n                        ptol = 1e-8,\n                        gtol = 1e-8,\n                        l = 1.,\n                        max_iter = 80,\n                    )\n\n    # parallel gauss-newton for several optimization problems at multiple costs\n    from torchimize.functions import lsq_gna_parallel\n    coeffs_list = lsq_gna_parallel(\n                        p = initials_batch,\n                        function = multi_cost_fun_batch,\n                        jac_function = multi_jac_fun_batch,\n                        args = (other_args,),\n                        wvec = torch.ones(5, device='cuda', dtype=initials_batch.dtype),\n                        ftol = 1e-8,\n                        ptol = 1e-8,\n                        gtol = 1e-8,\n                        l = 1.,\n                        max_iter = 80,\n                    )\n\n    # parallel levenberg-marquardt for several optimization problems at multiple costs\n    from torchimize.functions import lsq_lma_parallel\n    coeffs_list = lsq_lma_parallel(\n                        p = initials_batch,\n                        function = multi_cost_fun_batch,\n                        jac_function = multi_jac_fun_batch,\n                        args = (other_args,),\n                        wvec = torch.ones(5, device='cuda', dtype=initials_batch.dtype),\n                        ftol = 1e-8,\n                        ptol = 1e-8,\n                        gtol = 1e-8,\n                        meth = 'marq',\n                        max_iter = 40,\n                    )\n\n    # validate that your provided functions return correct tensor dimensionality\n    from torchimize.functions import test_fun_dims_parallel\n    ret = test_fun_dims_parallel(\n        p = initials_batch,\n        function = multi_cost_fun_batch,\n        jac_function = multi_jac_fun_batch,\n        args = (other_args,),\n        wvec = torch.ones(5, device='cuda', dtype=initials_batch.dtype),\n    )\n\n.. note::\n    For simultaneous minimization of ``B`` optimization problems at a multiple of ``C`` costs, the ``function`` and ``jac_function`` arguments require to return a torch.Tensor type of ``B x C x N`` and ``B x C x N x P``, respectively. Here, ``N`` is the residual dimension and ``P`` represents the sought parameter number in each ``B x C``.\n\nFor further details, see the `API documentation \u003chttps://hahnec.github.io/torchimize/build/html/apidoc.html\u003e`_.\n\n.. substitutions\n\n.. |logo| image:: https://github.com/hahnec/torchimize/blob/develop/docs/torchimize_logo_font.svg\n    :target: https://hahnec.github.io/torchimize/\n    :width: 400 px\n    :scale: 100 %\n    :alt: torchimize\n\n.. |coverage| image:: https://coveralls.io/repos/github/hahnec/torchimize/badge.svg?branch=master\n    :target: https://coveralls.io/github/hahnec/torchimize\n    :width: 98\n\n.. |tests_develop| image:: https://img.shields.io/github/actions/workflow/status/hahnec/torchimize/gh_actions.yaml?branch=develop\u0026style=square\u0026label=develop\n    :target: https://github.com/hahnec/torchimize/actions/\n    :width: 105\n\n.. |tests_master| image:: https://img.shields.io/github/actions/workflow/status/hahnec/torchimize/gh_actions.yaml?branch=master\u0026style=square\u0026label=master\n    :target: https://github.com/hahnec/torchimize/actions/\n    :width: 100\n\n.. |license| image:: https://img.shields.io/badge/License-GPL%20v3.0-orange.svg?logoWidth=40\n    :target: https://www.gnu.org/licenses/gpl-3.0.en.html\n    :alt: License\n    :width: 150\n\n.. |pypi| image:: https://img.shields.io/pypi/dm/torchimize?label=PyPI%20downloads\n    :target: https://pypi.org/project/torchimize/\n    :alt: PyPI Downloads\n    :width: 162\n\nCitation\n========\n\n.. code-block:: BibTeX\n\n    @misc{torchimize,\n        title={torchimize},\n        author={Hahne, Christopher and Hayoz, Michel},\n        year={2022},\n        publisher = {GitHub},\n        journal = {GitHub repository},\n        howpublished = {\\url{https://github.com/hahnec/torchimize}}\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhahnec%2Ftorchimize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhahnec%2Ftorchimize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhahnec%2Ftorchimize/lists"}