This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.sparse as sp | |
import torch | |
import torch.nn as nn | |
from torch.utils.data import DataLoader, Dataset | |
def one_hot(index, n_cat): | |
onehot = torch.zeros(index.size(0), n_cat, device=index.device) | |
onehot.scatter_(1, index.type(torch.long), 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import scipy.sparse as sp | |
def test_sparse_tensor(): | |
# That is sparse for sure | |
data = np.random.binomial(1, 0.01, size=(128, 27000)) | |
csr_matrix = sp.csr_matrix(data) | |
indptr = csr_matrix.indptr | |
indices = csr_matrix.indices | |
i = torch.LongTensor(np.array([[l, j] for l, i in enumerate(range(len(indptr) - 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import numpy as np | |
import torch | |
from scvi.dataset.dataset import GeneExpressionDataset | |
from scvi.dataset.synthetic import SyntheticDataset | |
class NamedDataset1(GeneExpressionDataset): |