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

swh:1:snp:00a09dfe75d92a5d9631593944db4c280ca40ab3
  • Code
  • Branches (1)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    No releases to show
  • e84a592
  • /
  • src
  • /
  • datasets
  • /
  • cadena.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
  • revision
  • snapshot
content badge
swh:1:cnt:1c307f081d349e9691993a2e1062fc191088ff4f
directory badge
swh:1:dir:44dbae8a3602ecf2bce3ca35c8b38bcab0f026c0
revision badge
swh:1:rev:9eccfe575524736f25f4f3759fe04648f22554de
snapshot badge
swh:1:snp:00a09dfe75d92a5d9631593944db4c280ca40ab3

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
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 9eccfe575524736f25f4f3759fe04648f22554de authored by Luke Taylor on 09 April 2024, 14:00:54 UTC
Added brainbox version.
Tip revision: 9eccfe5
cadena.py
import sys

import torch

from src.datasets.base import BaseDataset


class CadenaDataset(BaseDataset):

    def __init__(self, root, split, ntau, normalise=True, scale=1):
        super().__init__(normalise, scale, False)
        # Load dependencies
        sys.path.append(f"{root}/dependencies/Cadena2019PlosCB")
        from cnn_sys_ident import data as cadena_data
        data_dict = cadena_data.Dataset.get_clean_data()
        data = cadena_data.MonkeyDataset(data_dict, seed=1000, train_frac=0.8, subsample=1, crop=14)

        if split == "train":
            x_train, y_train, _ = data.train()
            x_val, y_val, _ = data.val()
            x_train = torch.from_numpy(x_train)
            y_train = torch.from_numpy(y_train)
            x_val = torch.from_numpy(x_val)
            y_val = torch.from_numpy(y_val)
            self._x = torch.cat([x_train, x_val])
            self._y = torch.cat([y_train, y_val])
        elif split == "test":
            x_test, y_test, _ = data.test()
            self._x = torch.from_numpy(x_test)
            self._y = torch.from_numpy(y_test).permute(1, 0, 2)

        if split == "train":
            self._y = self._y.unsqueeze(1)

        self._x = self._x.permute(0, 3, 1, 2).repeat(1, ntau, 1, 1).unsqueeze(1)

    def __len__(self):
        return len(self._x)

    def _get_dimensions(self):
        return 112, 112

    def _get_mean_std(self):
        return -0.0009, 0.9993

    def _get_dataset_item(self, i):
        x, y = self._x[i], self._y[i]

        return x, y.permute(1, 0)

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