Skip to content

Instantly share code, notes, and snippets.

View ferrine's full-sized avatar

Maxim Kochurov ferrine

View GitHub Profile
@ferrine
ferrine / bayes.py
Created August 3, 2016 22:35
bayes by backprop wrapping
import math
from functools import wraps
from theano import tensor as T
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
from lasagne import init
from lasagne.random import get_rng
__all__ = ['Accumulator', 'NormalApproximation', 'NormalApproximationScMix', 'bbpwrap']
Coal, peat and oil shale-Production (ktoe)
Coal, peat and oil shale-Imports (ktoe)
Coal, peat and oil shale-Exports (ktoe)
Coal, peat and oil shale-Total primary energy supply (ktoe)
Coal, peat and oil shale-Electricity plants (ktoe)
Coal, peat and oil shale-CHP plants (ktoe)
Coal, peat and oil shale-Heat plants (ktoe)
Coal, peat and oil shale-Oil refineries, transformation (ktoe)
Coal, peat and oil shale-Total final consumption (ktoe)
Coal, peat and oil shale-Industry (ktoe)
@ferrine
ferrine / macos-air-keymap
Last active February 17, 2018 15:32
xkb macbook-air-un-ru keyboard
xkb_keymap {
xkb_keycodes "(unnamed)" {
minimum = 8;
maximum = 255;
<ESC> = 9;
<AE01> = 10;
<AE02> = 11;
<AE03> = 12;
<AE04> = 13;
<AE05> = 14;
@ferrine
ferrine / optnote.tex
Last active March 27, 2018 12:50
Latex optional gray C++ style author notes
\newif\ifIncludeAuthorNotes
% Comment the below line to remove notes from text
\IncludeAuthorNotestrue
\DeclareRobustCommand{\note}[1]{
\ifIncludeAuthorNotes
% the below line skips are intentional and force comment to be on a separate line
\textcolor{gray}{/* #1 */}
@ferrine
ferrine / installdockerandcompose.sh
Created April 8, 2018 10:23
install Docker and Compose
curl -fsSL get.docker.com | sh \
&& sudo curl -L https://github.com/docker/compose/releases/download/1.20.1/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose \
&& sudo chmod +x /usr/local/bin/docker-compose
@ferrine
ferrine / pre-commit
Created April 8, 2018 13:04
pre commit hook that uses git secret
git secret hide && git add $(git secret list | awk -v ext=${SECRETS_EXTENSION:-secret} '{print $1"."ext}')
@ferrine
ferrine / random_subimages.py
Last active May 23, 2018 16:01
Random batch subimages numpy
def random_subimages_idx(n, d1, d2, h, w):
hs = np.random.randint(d1-h, size=n)
ws = np.random.randint(d2-w, size=n)
grid = np.meshgrid(np.arange(h), np.arange(w), indexing='ij')
i = np.tile(np.arange(n)[:, None, None], (h, w))
xs = grid[0]+hs[:, None, None]
ys = grid[1]+ws[:, None, None]
return i, xs, ys
def random_subimages(images, h, w):
@ferrine
ferrine / sample_swap.py
Last active June 22, 2018 11:01
sample swap for image (batch, cannel, height, width*2)
def sample_swap(shape):
b, c, h, w = shape
left = np.arange(0, w//2)
right = np.arange(w//2, w)
flip = np.random.uniform(size=(b, 1)) > .5
b = np.arange(b)[:, None, None, None]
c = np.arange(c)[None, :, None, None]
h = np.arange(h)[None, None, :, None]
w = np.concatenate([left+flip*(w//2), right-flip*(w//2)], -1)
w = w[:, None, None, :]
@ferrine
ferrine / Convergence_Checks.ipynb
Created July 4, 2018 21:53
Convergence Checks for Mixture model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ferrine
ferrine / BetaKLExample.ipynb
Created July 4, 2018 22:37
Usage of Beta KL PyMC3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.