Skip to content

Instantly share code, notes, and snippets.

View kklemon's full-sized avatar

Kristian Klemon kklemon

  • Munich
View GitHub Profile
@kklemon
kklemon / midi-program-change-events.json
Last active June 27, 2018 14:50
JSON file containing all MIDI program change events with the event number and instrument name hierarchically categorized. Parsed from https://en.wikipedia.org/wiki/General_MIDI#Program_change_events
[
{
"instruments": [
{
"name": "Acoustic Grand Piano",
"program": 1
},
{
"name": "Bright Acoustic Piano",
"program": 2
@kklemon
kklemon / imagenet_class_labels.txt
Last active February 19, 2021 08:48
ImageNet ILSVRC2011 class label meta data
1 n02119789 kit fox, Vulpes macrotis
2 n02100735 English setter
3 n02096294 Australian terrier
4 n02066245 grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus
5 n02509815 lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens
6 n02124075 Egyptian cat
7 n02417914 ibex, Capra ibex
8 n02123394 Persian cat
9 n02125311 cougar, puma, catamount, mountain lion, painter, panther, Felis concolor
10 n02423022 gazelle
@kklemon
kklemon / iterable_dataset_dist.py
Last active November 1, 2024 09:04
PyTorch IterableDataset implementation with multiprocessing and distributed training support
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.utils.data import IterableDataset, DataLoader
class DistributedIterableDataset(IterableDataset):
"""
Example implementation of an IterableDataset that handles both multiprocessing (num_workers > 0)
@kklemon
kklemon / dash_bio_residue_coloring.py
Created January 26, 2023 16:00
Sample code for residue coloring in a dash-bio 3d molecule view
"""
Sample code for residue coloring in a dash-bio 3d molecule view
Requirements:
- dash
- dash-bio
- numpy
- biopython
pip install dash dash-bio numpy biopython
@kklemon
kklemon / pytorch_transformer_benchmark.py
Last active October 31, 2024 17:48
PyTorch Transformer Benchmark
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
bz = 128
seq_len = 512
d_model = 64
n_heads = 8
@kklemon
kklemon / flash-attention-2-transformer.py
Last active March 22, 2024 15:01
PyTorch Transformer API compatible wrapper around FlashAttention-2
import torch.nn as nn
import torch.nn.functional as F
class FlashAttentionTransformerEncoder(nn.Module):
def __init__(
self,
dim_model,
num_layers,
num_heads=None,
@kklemon
kklemon / mri_tensordicts.py
Last active February 1, 2024 08:50
Exemplary showcase implementation of MRI sequence handling with TensorDicts and memory mapped tensors
import torch
import nibabel as nib
import numpy as np
from tensordidct import TensorDict, MemmapTensor
files_by_modality = {
'flair': [...]
}
num_files = ...
@kklemon
kklemon / kiba_ligands.csv
Created September 29, 2024 15:09
kiba_ligands.csv
ligand_id smiles
CHEMBL1087421 COC1=C(C=C2C(=C1)CCN=C2C3=CC(=C(C=C3)Cl)Cl)Cl
CHEMBL1088633 COC1=C(C=C2C(=C1)CCN=C2C3=CC(=CC=C3)Cl)Cl
CHEMBL1090360 C1COCCN1C2=CC(=CC=C2)NC3=NC=CC(=N3)C4=C(N=C5N4C=CS5)C6=CC(=CC=C6)NC(=O)CC7=CC=CC=C7
CHEMBL1688215 C1=CC2=C(C=C1C3=NC(=NC=C3)N)NN=C2N
CHEMBL1765781 CNC1=NC(=CN=C1)C2=CNC(=O)C(=C2)NC(=O)C3=CC=C(C=C3)N4CCCC4CN5CCCC5
CHEMBL1788116 C1=CC=C2C(=C1)NC(=C(C#N)C3=NC(=NC=C3)NCCC4=CN=CC=C4)S2.C(=O)(C(F)(F)F)O.C(=O)(C(F)(F)F)O
CHEMBL1929238 CC(C)(C)C1=CC(=C(S1)NC(=O)NC2=C(C(=CC=C2)Cl)Cl)C(=O)N3CCC(=O)N(CC3)CCN(C)C
CHEMBL1933552 CC1CCC(CN1)N2CCC3(C2)CN(C4=CC=CC=C34)C(=O)C5=CC6=C(N5)C=C(C=C6)F
CHEMBL202930 COC1=C(C=CC(=C1)C2=CC3=C(C=C2)C(=CC4=CC=CN4)C(=O)N3)O