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

  • d14115e
  • /
  • tensorly
  • /
  • __init__.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.

  • content
  • directory
content badge
swh:1:cnt:e0667faf2eaa92a32c7c16cfff5c363e4493b640
directory badge
swh:1:dir:635dd79e77175591a7ac36b54c79c8675bfe64fb

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
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
__init__.py
import sys
import importlib
import os

__version__ = '0.4.0'

# Set the default backend
default_backend = 'numpy'
try:
    if _BACKEND is None:
        _BACKEND = os.environ.get('TENSORLY_BACKEND', default_backend)
except NameError:
    _BACKEND = os.environ.get('TENSORLY_BACKEND', default_backend)

def set_backend(backend_name):
    """Sets the backend for TensorLy

        The backend will be set as specified and operations will used that backend

    Parameters
    ----------
    backend_name : {'mxnet', 'numpy', 'pytorch', 'tensorflow', 'cupy'}, default is 'numpy'
    """
    global _BACKEND
    _BACKEND = backend_name

    # reloads tensorly.backend
    importlib.reload(backend)

    # reload from .backend import * (e.g. tensorly.tensor)
    globals().update(
            {fun: getattr(backend, fun) for n in backend.__all__} if hasattr(backend, '__all__') 
            else 
            {k: v for (k, v) in backend.__dict__.items() if not k.startswith('_')
            })

def get_backend():
    """Returns the backend currently used

    Returns
    -------
    backend_used : str
        the backend currently in use
    """
    global _BACKEND
    backend_used = _BACKEND
    return backend_used

from .backend import *
from .base import unfold, fold
from .base import tensor_to_vec, vec_to_tensor                                                                                                           
from .base import partial_unfold, partial_fold
from .base import partial_tensor_to_vec, partial_vec_to_tensor

from .kruskal_tensor import kruskal_to_tensor, kruskal_to_unfolded, kruskal_to_vec
from .tucker_tensor import tucker_to_tensor, tucker_to_unfolded, tucker_to_vec


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