{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/optnet-differentiable-optimization-as-a-layer","title":"OptNet: Differentiable Optimization as a Layer in Neural Networks","arxiv_id":"1703.00443","date":"2017-03-01","proceeding":"ICML 2017 8","authors":["Brandon Amos","J. Zico Kolter"],"abstract":"This paper presents OptNet, a network architecture that integrates optimization problems (here, specifically in the form of quadratic programs) as individual layers in larger end-to-end trainable deep networks. These layers encode constraints and complex dependencies between the hidden states that traditional convolutional and fully-connected layers often cannot capture. We explore the foundations for such an architecture: we show how techniques from sensitivity analysis, bilevel optimization, and implicit differentiation can be used to exactly differentiate through these layers and with respect to layer parameters; we develop a highly efficient solver for these layers that exploits fast GPU-based batch solves within a primal-dual interior point method, and which provides backpropagation gradients with virtually no additional cost on top of the solve; and we highlight the application of these approaches in several problems. In one notable example, the method is learns to play mini-Sudoku (4x4) given just input and output games, with no a-priori information about the rules of the game; this highlights the ability of OptNet to learn hard constraints better than other neural architectures.","url_abs":"https://arxiv.org/abs/1703.00443v5","url_pdf":"https://arxiv.org/pdf/1703.00443v5.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"optnet-differentiable-optimization-as-a-layer","repo_url":"https://github.com/locuslab/optnet","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"optnet-differentiable-optimization-as-a-layer","repo_url":"https://github.com/Kyubyong/sudoku","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"tf","reach":{"status":"ok","spdx":"GPL-3.0"}},{"paper_slug":"optnet-differentiable-optimization-as-a-layer","repo_url":"https://github.com/kevin-tracy/qpax","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"NOASSERTION"}},{"paper_slug":"optnet-differentiable-optimization-as-a-layer","repo_url":"https://github.com/locuslab/e2e-model-learning","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"optnet-differentiable-optimization-as-a-layer","repo_url":"https://github.com/mitmath/matrixcalc","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok"}},{"paper_slug":"optnet-differentiable-optimization-as-a-layer","repo_url":"https://github.com/msakai/chainer-optnet","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"optnet-differentiable-optimization-as-a-layer","repo_url":"https://github.com/pfnet-research/chainer-differentiable-mpc","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"optnet-differentiable-optimization-as-a-layer","repo_url":"https://github.com/quentinll/diffqcqp","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"torch","reach":{"status":"ok","spdx":"BSD-2-Clause"}}],"tasks":[{"task_slug":"bilevel-optimization","task_name":"Bilevel Optimization"},{"task_slug":null,"task_name":"GPU"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/1703.00443","atlas_url":"https://app.syntology.ai/?focus=1703.00443","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1703.00443"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/quentinll/diffqcqp","reach":{"status":"ok","spdx":"BSD-2-Clause"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/locuslab/optnet","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/msakai/chainer-optnet","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mitmath/matrixcalc","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Kyubyong/sudoku","reach":{"status":"ok","spdx":"GPL-3.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/pfnet-research/chainer-differentiable-mpc","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/locuslab/e2e-model-learning","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/kevin-tracy/qpax","reach":{"status":"ok","spdx":"NOASSERTION"}}],"summary":{"unverified":16},"by_repo_kind":{"official":{"samples":7,"ran":0,"repositories":1},"listed":{"samples":9,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"1ba2d4c26bccdc35","entry":"bdiag","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/solvers/pdipm_batch.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/solvers/pdipm_batch.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"1ba2d4c26bccdc35"}},{"code_sha256_prefix":"c28b7bb019347e9f","entry":"beye","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/solvers/pdipm_batch.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/solvers/pdipm_batch.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c28b7bb019347e9f"}},{"code_sha256_prefix":"4c4e504d2a7ae4a8","entry":"cho_factor_partial","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/solvers/pdipm_single.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/solvers/pdipm_single.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4c4e504d2a7ae4a8"}},{"code_sha256_prefix":"8ce0efe56f0daa69","entry":"construct_puzzle_solution","repo":"locuslab/optnet","repo_kind":"official","path":"sudoku/create.py","file_url":"https://github.com/locuslab/optnet/blob/HEAD/sudoku/create.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8ce0efe56f0daa69"}},{"code_sha256_prefix":"34bed16bc8599ae8","entry":"get_array_module","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/pivots.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/pivots.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"34bed16bc8599ae8"}},{"code_sha256_prefix":"19e15be4c1990dda","entry":"get_sizes","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/solvers/pdipm_single.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/solvers/pdipm_single.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"19e15be4c1990dda"}},{"code_sha256_prefix":"7498ea1bc2aeae12","entry":"get_sudoku_matrix","repo":"locuslab/optnet","repo_kind":"official","path":"sudoku/models.py","file_url":"https://github.com/locuslab/optnet/blob/HEAD/sudoku/models.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7498ea1bc2aeae12"}},{"code_sha256_prefix":"57b83d82c3f1dd96","entry":"perm_to_pivots","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/pivots.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/pivots.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"57b83d82c3f1dd96"}},{"code_sha256_prefix":"c2853a223af6c5e9","entry":"pivots_to_perm","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/pivots.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/pivots.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c2853a223af6c5e9"}},{"code_sha256_prefix":"c49fa6ae7dc3e337","entry":"quadprog","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/solvers/cvxpy.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/solvers/cvxpy.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c49fa6ae7dc3e337"}},{"code_sha256_prefix":"fb7526f10c27f4b9","entry":"quadprog","repo":"msakai/chainer-optnet","repo_kind":"listed","path":"chainer_optnet/solvers/pdipm_single.py","file_url":"https://github.com/msakai/chainer-optnet/blob/HEAD/chainer_optnet/solvers/pdipm_single.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"fb7526f10c27f4b9"}},{"code_sha256_prefix":"76cc7194ae64e0dc","entry":"rolling","repo":"locuslab/optnet","repo_kind":"official","path":"cls/plot.py","file_url":"https://github.com/locuslab/optnet/blob/HEAD/cls/plot.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"76cc7194ae64e0dc"}},{"code_sha256_prefix":"45ceda97985f082a","entry":"rolling","repo":"locuslab/optnet","repo_kind":"official","path":"denoising/plot.py","file_url":"https://github.com/locuslab/optnet/blob/HEAD/denoising/plot.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"45ceda97985f082a"}},{"code_sha256_prefix":"980d886059335925","entry":"sample","repo":"locuslab/optnet","repo_kind":"official","path":"denoising/create.py","file_url":"https://github.com/locuslab/optnet/blob/HEAD/denoising/create.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"980d886059335925"}},{"code_sha256_prefix":"36fa1e9e7a5ed275","entry":"sample","repo":"locuslab/optnet","repo_kind":"official","path":"sudoku/create.py","file_url":"https://github.com/locuslab/optnet/blob/HEAD/sudoku/create.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"36fa1e9e7a5ed275"}},{"code_sha256_prefix":"7172da2c67065223","entry":"toOneHot","repo":"locuslab/optnet","repo_kind":"official","path":"sudoku/create.py","file_url":"https://github.com/locuslab/optnet/blob/HEAD/sudoku/create.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7172da2c67065223"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}