Skip to content

Instantly share code, notes, and snippets.

View jacobkimmel's full-sized avatar

Jacob Kimmel jacobkimmel

View GitHub Profile
@jacobkimmel
jacobkimmel / forest_lab_kidney_preservation_comparison.ipynb
Created June 2, 2023 21:30
forest_lab_kidney_preservation_comparison.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jacobkimmel
jacobkimmel / load_dense_as_sparse.py
Created August 9, 2021 17:42
Load dense count arrays as `scipy.sparse` matrices
import gzip
import scipy.sparse as sp
import numpy as np
def load_dense_csv_as_sparse_matrix(
file_name: str,
dtype=np.int32,
skip_lines: int=0,
batch_size: int=2048,
@jacobkimmel
jacobkimmel / make_one_hot.py
Last active May 15, 2021 04:02
Generate one hot labels from integer labels in PyTorch
def make_one_hot(labels, C=2):
'''
Converts an integer label torch.autograd.Variable to a one-hot Variable.
Parameters
----------
labels : torch.autograd.Variable of torch.cuda.LongTensor
N x 1 x H x W, where N is batch size.
Each value is an integer representing correct classification.
C : integer.