Skip to content

Instantly share code, notes, and snippets.

View ferrine's full-sized avatar

Maxim Kochurov ferrine

View GitHub Profile
@ferrine
ferrine / screenlock
Created February 15, 2020 11:21
i3lock-bluring-4K
#!/bin/zsh
magick convert -size 3840x2160 <(scrot -o /dev/stdout)'[384x216]' -blur 0x5 -resize 1000% RGB:- | i3lock --raw 3840x2160:rgb --image /dev/stdin
@ferrine
ferrine / mobius_linear.py
Created July 4, 2019 13:56
Mobius Linear example
import torch.nn
import geoopt
# package.nn.modules.py
def create_ball(ball=None, c=None):
if ball is None:
assert c is not None, "curvature of the ball should be explicitly specified"
ball = geoopt.PoincareBall(c)
elif not isinstance(ball, geoopt.PoincareBall):
raise ValueError("ball should be an instance of PoncareMall")
return ball
@ferrine
ferrine / playground.ipynb
Last active May 5, 2019 23:18
pymc4 playground
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ferrine
ferrine / tensorboard_observer.py
Created April 11, 2019 11:46
Tensorboard sacred observer
import sacred.observers
import tensorboardX
import os
class TensorboardObserver(sacred.observers.FileStorageObserver, tensorboardX.SummaryWriter):
VERSION = "TensorboardObserver-0.0.1"
def __init__(self, basedir, resource_dir=None, source_dir=None,
template=None, priority=sacred.observers.file_storage.DEFAULT_FILE_STORAGE_PRIORITY,
@ferrine
ferrine / network_builder.py
Last active November 10, 2023 04:43
Pytorch models from yaml files
import torch.nn
import collections
class Builder(object):
def __init__(self, *namespaces):
self._namespace = collections.ChainMap(*namespaces)
def __call__(self, name, *args, **kwargs):
try:
return self._namespace[name](*args, **kwargs)
@ferrine
ferrine / nested_map.py
Created April 2, 2019 09:04
solution to catalyst fp16 forward
import torch
def map_nested(fn, structure, cond=lambda obj: isinstance(obj, torch.Tensor)):
r"""
Applies fn to an object in a possibly nested data structure and returns same
structure with every element changed if condition satisfied.
"""
def inner_map(obj):
if cond(obj):
return fn(obj)
@ferrine
ferrine / benchmarks-0.4.1.ipynb
Created January 27, 2019 20:46
geoopt-stiefel-benchmark
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ferrine
ferrine / fft.ipynb
Created November 28, 2018 13:16
FFT study
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ferrine
ferrine / svdn.py
Last active September 16, 2019 12:11
multidimensional svd pytorch
import itertools
import torch
def svd(x):
# https://discuss.pytorch.org/t/multidimensional-svd/4366/2
batches = x.shape[:-2]
if batches:
n, m = x.shape[-2:]
k = min(n, m)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.