Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 1db48f3a735eb0fba06a7d503f080a7ead512604 authored by Artem Artemev on 11 July 2018, 12:50:44 UTC, committed by GitHub on 11 July 2018, 12:50:44 UTC
Update version.py file to 1.2.0 (#812)
1 parent 707b195
  • Files
  • Changes
  • 2109064
  • /
  • tests
  • /
  • test_multioutput_features.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:1db48f3a735eb0fba06a7d503f080a7ead512604
directory badge
swh:1:dir:159581b27232f9d682bced21f4ae14b62cdb6e1b
content badge
swh:1:cnt:da304b7b6ed100ccbdac86ce873f7248e1777018

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
test_multioutput_features.py
import gpflow
import gpflow.multioutput.features as mf
import gpflow.multioutput.kernels as mk
import numpy as np
import pytest
import tensorflow as tf
from gpflow.features import InducingPoints
from gpflow.kernels import RBF
from gpflow.likelihoods import Gaussian
from gpflow.models import SVGP
from gpflow.test_util import session_tf


float_type = gpflow.settings.float_type
np.random.seed(1)


class Datum:
    D = 1
    L = 2
    P = 3
    M = 10
    N = 100
    W = np.random.randn(P, L)
    X = np.random.randn(N)[:, None]
    Xnew = np.random.randn(N)[:, None]


def make_kernel():
    return gpflow.kernels.RBF(Datum.D)


def make_kernels(num):
    return [make_kernel() for _ in range(num)]


def make_ip():
    x = np.random.permutation(Datum.X)
    return gpflow.features.InducingPoints(x[:Datum.M, ...])


def make_ips(num):
    return [make_ip() for _ in range(num)]


class Mofs:
    def shared_independent(self):
        return mf.SharedIndependentMof(make_ip())

    def separate_independent(self, num=Datum.P):
        return mf.SeparateIndependentMof(make_ips(num))

    def features(self):
        return [self.shared_independent, self.separate_independent]

    def mixed_shared(self):
        return mf.MixedKernelSharedMof(make_ip())


class Moks:
    def shared_independent(self):
        return mk.SharedIndependentMok(make_kernel(), Datum.P)

    def separate_independent(self, num=Datum.L):
        return mk.SeparateIndependentMok(make_kernels(num))

    def separate_mixed(self, num=Datum.L):
        return mk.SeparateMixedMok(make_kernels(num), Datum.W)

    def kernels(self):
        return [self.shared_independent, self.separate_independent, self.separate_mixed]


@pytest.mark.parametrize('feature', Mofs().features())
@pytest.mark.parametrize('kernel', Moks().kernels())
def test_kuu(session_tf, feature, kernel):
    Kuu = mf.Kuu(feature(), kernel(), jitter=1e-9)
    session_tf.run(tf.cholesky(Kuu))


@pytest.mark.parametrize('feature', Mofs().features())
@pytest.mark.parametrize('kernel', Moks().kernels())
def test_kuf(session_tf, feature, kernel):
    Kuf = mf.Kuf(feature(), kernel(), Datum.Xnew)
    session_tf.run(Kuf)


@pytest.mark.parametrize('fun', [mf.Kuu, mf.Kuf])
def test_mixed_shared(session_tf, fun):
    f = Mofs().mixed_shared()
    k = Moks().separate_mixed()
    if fun is mf.Kuu:
        t = tf.cholesky(fun(f, k, jitter=1e-9))
    else:
        t = fun(f, k, Datum.Xnew)
        print(t.shape)
    session_tf.run(t)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API