Skip to content

Instantly share code, notes, and snippets.

View MischaPanch's full-sized avatar

Michael Panchenko MischaPanch

  • appliedAI
  • Munich
View GitHub Profile
@MischaPanch
MischaPanch / fast_torch_loaders.py
Created August 10, 2023 17:42
Accelerated torch dataset and dataloader
import numpy as np
import torch
from torch.utils.data import Dataset, Subset, TensorDataset
from typing import (
Callable,
Iterator,
Literal,
Optional,
Sequence,
Tuple,
@MischaPanch
MischaPanch / funcops.py
Last active December 17, 2021 10:51
Allowing overloading of operators like +, *, @ and so on for functions in python
import logging
import operator as o
from typing import Callable, Union, Any, Type
log = logging.getLogger()
class _FunctionWrapper:
def __init__(self, function: Callable, name: str = None):
self.function = function
@MischaPanch
MischaPanch / datastruct.py
Last active August 23, 2021 10:46
Base class with attribute and dict like access, with IDE support for attributes and keys
import json
from abc import ABC, abstractmethod
from copy import copy
from enum import Enum
from typing import Generic, List, Type, TypeVar, get_args
import numpy as np
class KeyEnum(str, Enum):