{"id":26892014,"url":"https://github.com/dnv-opensource/gpytorch-mogp","last_synced_at":"2026-02-15T20:33:48.288Z","repository":{"id":267626025,"uuid":"901833625","full_name":"dnv-opensource/gpytorch-mogp","owner":"dnv-opensource","description":"A package which extends GPyTorch with correlated multi-output GPs","archived":false,"fork":false,"pushed_at":"2024-12-11T13:03:31.000Z","size":575,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-11T11:11:33.905Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dnv-opensource.png","metadata":{"files":{"readme":"README.md","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,"zenodo":null}},"created_at":"2024-12-11T11:59:50.000Z","updated_at":"2024-12-11T13:03:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"1242e1f6-39fe-4139-9d69-6a8b31a92ce1","html_url":"https://github.com/dnv-opensource/gpytorch-mogp","commit_stats":null,"previous_names":["dnv-opensource/gpytorch-mogp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dnv-opensource/gpytorch-mogp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fgpytorch-mogp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fgpytorch-mogp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fgpytorch-mogp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fgpytorch-mogp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnv-opensource","download_url":"https://codeload.github.com/dnv-opensource/gpytorch-mogp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnv-opensource%2Fgpytorch-mogp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29488602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T19:29:10.908Z","status":"ssl_error","status_checked_at":"2026-02-15T19:29:10.419Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-03-31T22:48:53.716Z","updated_at":"2026-02-15T20:33:48.271Z","avatar_url":"https://github.com/dnv-opensource.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gpytorch-mogp\n\n[![PyPI - Version](https://img.shields.io/pypi/v/gpytorch-mogp.svg)](https://pypi.org/project/gpytorch-mogp)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/gpytorch-mogp.svg)](https://pypi.org/project/gpytorch-mogp)\n[![license](https://img.shields.io/pypi/l/gpytorch-mogp.svg)](https://github.com/dnv-opensource/gpytorch-mogp/blob/main/LICENSE)\n\n`gpytorch-mogp` is a Python package that extends [GPyTorch](https://gpytorch.ai/) to support Multiple-Output Gaussian\nprocesses where the correlation between the outputs is known.\n\n\u003e **Note:** The package is currently in an early stage of development. Expect bugs and breaking changes in future\n\u003e versions. Please create an issue if you encounter any problems or have any suggestions.\n\n-----\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Known Issues](#known-issues)\n- [Glossary](#glossary)\n- [TODO](#todo)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\n```shell\npip install gpytorch-mogp\n```\n\n\u003e **Note:** If you want to use GPU acceleration, you should manually install\n\u003e [PyTorch](https://pytorch.org/get-started/locally/) with CUDA support before running the above command.\n\nIf you want to run the [examples](examples), you should install the package from source instead. First, clone the\nrepository:\n\n```shell\ngit clone https://github.com/dnv-opensource/gpytorch-mogp.git\n```\n\nThen install the package with the `examples` dependencies:\n\n```shell\npip install .[examples]\n```\n\nTo run the [comparison notebook](examples/comparison_with_rapid_models.ipynb), you also need to install\n[`rapid-models`](https://github.com/RaPiD-models/rapid_models_dev2023) from source.\n\n\u003e **Note:** The version of `rapid-modles` linked to above is private at the time of writing, so you may not be able to\n\u003e install it.\n\n## Usage\n\nUsage is similar to the official [Multitask GP Regression](https://docs.gpytorch.ai/en/latest/examples/03_Multitask_Exact_GPs/Multitask_GP_Regression.html)\nexample.\n\nThe package provides a custom `MultiOutputKernel` module that is used similarly to `MultitaskKernel`, and a custom\n`FixedNoiseMultiOutputGaussianLikelihood` that is used similarly to `MultitaskGaussianLikelihood`. The\n`MultiOutputKernel` wraps one or more base kernels, producing a joint covariance matrix for the outputs. The\n`FixedNoiseMultiOutputGaussianLikelihood` allows for fixed noise to be added to the joint covariance matrix.\n\n```python\nimport gpytorch\nfrom gpytorch_mogp import MultiOutputKernel, FixedNoiseMultiOutputGaussianLikelihood\n\n# Define a multi-output GP model\nclass MultiOutputGPModel(gpytorch.models.ExactGP):\n    def __init__(self, train_x, train_y, likelihood):\n        super().__init__(train_x, train_y, likelihood)\n        # Reuse the `MultitaskMean` module from `gpytorch`\n        self.mean_module = gpytorch.means.MultitaskMean(gpytorch.means.ConstantMean(), num_tasks=2)\n        # Use the custom `MultiOutputKernel` module\n        self.covar_module = MultiOutputKernel(gpytorch.kernels.MaternKernel(), num_outputs=2)\n\n    def forward(self, x):\n        mean_x = self.mean_module(x)\n        covar_x = self.covar_module(x)\n        # Reuse the `MultitaskMultivariateNormal` distribution from `gpytorch`\n        return gpytorch.distributions.MultitaskMultivariateNormal(mean_x, covar_x)\n\n# Training data\ntrain_x = ... # (n,) or (n, num_inputs)\ntrain_y = ... # (n, num_outputs)\ntrain_noise = ...  # (n, num_outputs, num_outputs)\n\n# Initialize the model\nlikelihood = FixedNoiseMultiOutputGaussianLikelihood(noise=train_noise, num_tasks=2)\nmodel = MultiOutputGPModel(train_x, train_y, likelihood)\n\n# Training\nmodel.train()\n...\n\n# Testing\nmodel.eval()\ntest_x = ... # (m,) or (m, num_inputs)\ntest_noise = ...  # (m, num_outputs, num_outputs)\nf_preds = model(test_x)\ny_preds = likelihood(model(test_x), noise=test_noise)\n```\n\u003e **Note:** `MultiOutputKernel` currently uses `num_outputs`, while `MultitaskMean` and\n\u003e `FixedNoiseMultiOutputGaussianLikelihood` use `num_tasks`. In this example, they mean the same thing. However, \n\u003e multi-output and multi-task can have different meanings in other contexts. The reason for this inconsistency is that\n\u003e the `num_tasks` argument comes from `gpytorch`, while the `num_outputs` argument comes from `gpytorch-mogp`\n\u003e (`FixedNoiseMultiOutputGaussianLikelihood` inherits it from `gpytorch`). This inconsistency may be addressed in future\n\u003e versions of the package.\n\n\u003e **Note:** The `MultiOutputKernel` produces an [_interleaved_ block diagonal covariance matrix](#glossary) by default,\n\u003e as that is the convention used in `gpytorch`. If you want to produce a [_non-interleaved_ block diagonal covariance\n\u003e matrix](#glossary), you can pass `interleaved=False` to the `MultiOutputKernel` constructor.\n\u003e\n\u003e `MultitaskMultivariateNormal` expects an interleaved block diagonal covariance matrix by default. If you want to use a\n\u003e non-interleaved block diagonal covariance matrix, you can pass `interleaved=False` to the\n\u003e `MultitaskMultivariateNormal` constructor.\n\u003e\n\u003e `FixedNoiseMultiOutputGaussianLikelihood` expects the same noise structure regardless of interleaving, but will\n\u003e internally apply interleaving to the noise before adding it to the covariance matrix. Interleaving is applied by\n\u003e default. If you want to avoid this, you can pass `interleaved=False` to the `FixedNoiseMultiOutputGaussianLikelihood`\n\u003e constructor. The likelihood should always use the same interleaving setting as the kernel.\n\u003e \n\u003e **WARNING:** The `interleaved=False` option is not working as expected at the moment. Avoid using it for now.\n\nSee also the [example notebooks/scripts](examples) for more usage examples.\n\nSee the [comparison notebook](examples/comparison_with_rapid_models.ipynb) for a comparison between the `gpytorch-mogp`\npackage and the `rapid-models` package (demonstrating that the two packages produce the same results for one example).\n\n## Known Issues\n- Constructing a GP with `interleaved=False` in `MultiOutputKernel`, `MultitaskMultivariateNormal`, and\n    `FixedNoiseMultiOutputGaussianLikelihood` does not work as expected. Avoid using `interleaved=False` for now.\n- The output of `MultiOutputKernel` is dense at the moment, as indexing into a block [linear operator]\n    (https://github.com/cornellius-gp/linear_operator) is not working as expected.\n- Important docstrings are missing.\n- The code style is not consistent with the `gpytorch` code style (note that `gpytorch` itself does not have a good and\n    consistent code style).\n- There are currently no tests for the package, except for some doctests in the docstrings. The primary goal is to\n    replicate the behavior of `rapid-models`, which is currently checked by comparing the results from _one_ example.\n- Most issues are probably unknown at this point. Please create an issue if you encounter any problems ...\n\n## Glossary\n- **Multi-output GP model**: A Gaussian process model that produces multiple outputs for a given input. I.e. a model\n    that predicts a vector-valued output for a given input.\n\n- **Multi-output kernel**: A kernel that wraps one or more base kernels, producing a joint covariance matrix for the\n    outputs. The joint covariance matrix is typically block diagonal, with each block corresponding to the output of a\n    single base kernel. \n\n- **Block matrix**: A matrix that is partitioned into blocks. E.g. a block matrix with $2$ blocks per side of size $3$ \n    is structured like:\n```math\n\\begin{bmatrix}\nA \u0026 B \\\\\nC \u0026 D\n\\end{bmatrix} = \\begin{bmatrix}\na_{11} \u0026 a_{12} \u0026 a_{13} \u0026 b_{11} \u0026 b_{12} \u0026 b_{13} \\\\\na_{21} \u0026 a_{22} \u0026 a_{23} \u0026 b_{21} \u0026 b_{22} \u0026 b_{23} \\\\\na_{31} \u0026 a_{32} \u0026 a_{33} \u0026 b_{31} \u0026 b_{32} \u0026 b_{33} \\\\\nc_{11} \u0026 c_{12} \u0026 c_{13} \u0026 d_{11} \u0026 d_{12} \u0026 d_{13} \\\\\nc_{21} \u0026 c_{22} \u0026 c_{23} \u0026 d_{21} \u0026 d_{22} \u0026 d_{23} \\\\\nc_{31} \u0026 c_{32} \u0026 c_{33} \u0026 d_{31} \u0026 d_{32} \u0026 d_{33}\n\\end{bmatrix}\n```\n\n- **Interleaved block matrix**: A block matrix where the blocks are interleaved. E.g. a block matrix with $2$ blocks per\n    side of size $3$ is structured like:\n```math\n\\begin{bmatrix}\na_{11} \u0026 b_{11} \u0026 a_{12} \u0026 b_{12} \u0026 a_{13} \u0026 b_{13} \\\\\nc_{11} \u0026 d_{11} \u0026 c_{12} \u0026 d_{12} \u0026 c_{13} \u0026 d_{13} \\\\\na_{21} \u0026 b_{21} \u0026 a_{22} \u0026 b_{22} \u0026 a_{23} \u0026 b_{23} \\\\\nc_{21} \u0026 d_{21} \u0026 c_{22} \u0026 d_{22} \u0026 c_{23} \u0026 d_{23} \\\\\na_{31} \u0026 b_{31} \u0026 a_{32} \u0026 b_{32} \u0026 a_{33} \u0026 b_{33} \\\\\nc_{31} \u0026 d_{31} \u0026 c_{32} \u0026 d_{32} \u0026 c_{33} \u0026 d_{33}\n\\end{bmatrix}\n```\n\n- **(Non-interleaved) block diagonal covariance matrix**: A joint covariance matrix that is block diagonal, with each\n    block corresponding to the output of a single base kernel. E.g. for a multi-output kernel with two base kernels,\n    $`K_{\\alpha}`$ and $`K_{\\beta}`$, the joint covariance matrix is given by:\n```math\nK(\\mathbf{X}, \\mathbf{X}^*) = \\begin{bmatrix}\nK_{\\alpha}(\\mathbf{X}, \\mathbf{X}^*) \u0026 \\mathbf{0} \\\\\n\\mathbf{0} \u0026 K_{\\beta}(\\mathbf{X}, \\mathbf{X}^*)\n\\end{bmatrix} = \\begin{bmatrix}\nK_{\\alpha}(\\mathbf{x}_1, \\mathbf{x}_1^*) \u0026 \\cdots \u0026 K_{\\alpha}(\\mathbf{x}_1, \\mathbf{x}_n^*)\\\\\n\\vdots \u0026 \\ddots \u0026 \\vdots \u0026 \u0026 \\mathbf{0} \u0026 \\\\\nK_{\\alpha}(\\mathbf{x}_N, \\mathbf{x}_1^*) \u0026 \\cdots \u0026 K_{\\alpha}(\\mathbf{x}_N, \\mathbf{x}_n^*) \u0026 \u0026 \u0026\\\\\n\u0026 \u0026 \u0026 K_{\\beta}(\\mathbf{x}_1, \\mathbf{x}_1^*) \u0026 \\cdots \u0026 K_{\\beta}(\\mathbf{x}_1, \\mathbf{x}_n^*)\\\\\n\u0026 \\mathbf{0} \u0026 \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots\\\\\n\u0026 \u0026 \u0026 K_{\\beta}(\\mathbf{x}_N, \\mathbf{x}_1^*) \u0026 \\cdots \u0026 K_{\\beta}(\\mathbf{x}_N, \\mathbf{x}_n^*)\n\\end{bmatrix}\n```\n\n- **Interleaved block diagonal covariance matrix**: Similar to a block diagonal covariance matrix, but with the blocks\n    interleaved:\n\n```math\nK(\\mathbf{X}, \\mathbf{X}^*) = \\begin{bmatrix}\nK_{\\alpha}(\\mathbf{x}_1, \\mathbf{x}_1^*) \u0026 \\mathbf{0} \u0026 \\cdots \u0026 K_{\\alpha}(\\mathbf{x}_1, \\mathbf{x}_n^*) \u0026 \\mathbf{0} \\\\\n\\mathbf{0} \u0026 K_{\\beta}(\\mathbf{x}_1, \\mathbf{x}_1^*) \u0026 \\cdots \u0026 \\mathbf{0} \u0026 K_{\\beta}(\\mathbf{x}_1, \\mathbf{x}_n^*) \\\\\n\\vdots \u0026 \\vdots \u0026 \\ddots \u0026 \\vdots \u0026 \\vdots \\\\\nK_{\\alpha}(\\mathbf{x}_N, \\mathbf{x}_1^*) \u0026 \\mathbf{0} \u0026 \\cdots \u0026 K_{\\alpha}(\\mathbf{x}_N, \\mathbf{x}_n^*) \u0026 \\mathbf{0} \\\\\n\\mathbf{0} \u0026 K_{\\beta}(\\mathbf{x}_N, \\mathbf{x}_1^*) \u0026 \\cdots \u0026 \\mathbf{0} \u0026 K_{\\beta}(\\mathbf{x}_N, \\mathbf{x}_n^*)\n\\end{bmatrix}\n```\n\n## Contributing\n\nContributions are welcome! Please create an issue or a pull request if you have any suggestions or improvements.\n\nTo get started contributing, clone the repository:\n\n```shell\ngit clone https://github.com/dnv-opensource/gpytorch-mogp.git\n```\n\nThen install the package in editable mode with `all` dependencies:\n```shell\npip install -e .[all]\n```\n\n## License\n\n`gpytorch-mogp` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnv-opensource%2Fgpytorch-mogp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnv-opensource%2Fgpytorch-mogp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnv-opensource%2Fgpytorch-mogp/lists"}