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

https://github.com/msmathcomp/hyperbolic-tsne
03 May 2024, 17:35:23 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • refs/heads/related_works
    No releases to show
  • 477dbb2
  • /
  • hyperbolicTSNE
  • /
  • initializations_.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

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.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:f814f03f65122326c192a4e3909680f499690b21
origin badgedirectory badge Iframe embedding
swh:1:dir:649e6af77a57c87647798bf148756724cab0ab03
origin badgerevision badge
swh:1:rev:bba9d0f089659fb170c7270aa90c796f91bfb2b1
origin badgesnapshot badge
swh:1:snp:9ac5f55368e393bdd437f6b15aab9fdb4f438510
Citations

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.

  • content
  • directory
  • revision
  • snapshot
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 ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: bba9d0f089659fb170c7270aa90c796f91bfb2b1 authored by Martin Skrodzki on 02 May 2024, 12:34:19 UTC
Update README.md
Tip revision: bba9d0f
initializations_.py
""" Methods for initializing embedding.
"""
import numpy as np
from sklearn.decomposition import PCA

from sklearn.utils import check_random_state


def initialization(n_samples, n_components, X=None, method="random", random_state=None):
    """
    Generates an initial embedding.

    Parameters
    ----------
    n_samples : int
        Number of samples (points) of the embedding.
    n_components : int
        Number of components (dimensions) of the embedding.
    X : ndarray, optional
        High-dimensional points if using method=`pca`.
    method : string, optional
        Method to use for generating the initial embedding.
        Should be a string in [random, pca]
    random_state : int
        To ensure reproducibility (used in sklearn `check_random_state` function.

    Returns
    -------
    X_embedded : ndarray
        array of shape (n_samples, n_components)
    """

    random_state = check_random_state(random_state)

    if method in ["pca"] and X is None:
        raise ValueError("The pca initialization requires the data X")

    if method == "random":
        X_embedded = 1e-4 * random_state.randn(n_samples, n_components).astype(np.float32)
    elif method == "pca":
        pca = PCA(n_components=n_components, svd_solver='randomized', random_state=random_state)
        X_embedded = pca.fit_transform(X).astype(np.float32, copy=False)
        X_embedded /= np.std(X_embedded[:, 0]) * 10000  # Need to rescale to avoid convergence issues
    else:
        raise ValueError(f"Method of initialization `{method}` not supported. init' must be 'pca', 'random', or a numpy array")

    return X_embedded

Software Heritage — Copyright (C) 2015–2025, 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— Contact— JavaScript license information— Web API

back to top