Skip to content

Instantly share code, notes, and snippets.

View daskol's full-sized avatar
🤙

Daniel Bershatsky daskol

🤙
View GitHub Profile
@daskol
daskol / tensorflow_dataset_unzip.py
Created March 8, 2021 19:18
Unzip a single input TensorFlow dataset to multiple ones.
from typing import Tuple
def unzip_dataset(dataset) -> Tuple[tf.data.Dataset, ...]:
"""Function unzip_dataset takes a single dataset which element spec is a
tuple and returns multiple datasets by number of tuple size of element spec.
:param dataset: Input dataset.
:return: Output tuple of datasets.
"""
@daskol
daskol / PKGBUILD
Created July 12, 2020 01:13
AUR Package for Apache Arrow
# Maintainer: Daniel Bershatsky <[email protected]>
pkgname=apache-arrow
pkgver=0.17.1
pkgrel=1
pkgdesc="Language-independent columnar memory format for flat and hierarchical data"
arch=('x86_64')
url='https://arrow.apache.org/'
license=('Apache')
depends=('boost-libs' 'jemalloc')
#!/usr/bin/env bash
# download.sh
declare -a archives=(
"https://data-static.usercontent.dev/DataClusteringSample0107.tar.gz"
"https://data-static.usercontent.dev/DataClusteringSample0817.tar.gz"
"https://data-static.usercontent.dev/DataClusteringSample1821.tar.gz"
)
for archive in ${archives[@]}; do
@daskol
daskol / mnist-with-jax.ipynb
Created August 9, 2019 09:27
Fix MNIST with Jax
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@daskol
daskol / fix-nbcounter.py
Created July 23, 2019 16:42
Fix execution counter of Jupyter notebook.
#!/usr/bin/env python3
# encoding: utf8
# filename: fix-nbcounter.py
"""This simple script load Jupyter notebook and fix execution counter.
"""
from json import load, dump
from sys import argv
with open(argv[1]) as fin:
@daskol
daskol / gensitemap.py
Last active July 11, 2019 22:16
Simple script to generate sitemap for a specified domain.
#!/usr/bin/env python3
# encoding: utf8
# filename: gensitemap.py
"""Simple script to generate sitemap for a specified domain. It traverse all
HTML files from a given root directory and build URLs.
"""
import logging
import xml.etree.ElementTree as etree
@daskol
daskol / moment-adjunctor.py
Created April 26, 2019 12:54
Moment Adjunctore for SGD Optimizer in PyTorch
# encoding: utf8
# filename: optimizer.py
import torch as T
def clip_momentum(value: float) -> float:
if value > 1.0:
return 1.0
elif value < 0.0:
@daskol
daskol / tt_maxout.py
Created April 19, 2019 09:56
Implementation of TT-Maxout unit in PyTorch
# encoding: utf8
# filename: maxout.py
import torch as T
import torch.nn.init as I
class TTMaxout(T.nn.Module):
def __init__(self, in_features, out_features, n_channels, tt_rank,
bias=True, irange=0.005):
@daskol
daskol / maxout.py
Created April 18, 2019 12:35
Maxout unit in PyTorch
import torch as T
class Maxout(T.nn.Module):
"""Class Maxout implements maxout unit introduced in paper by Goodfellow et al, 2013.
:param in_feature: Size of each input sample.
:param out_feature: Size of each output sample.
:param n_channels: The number of linear pieces used to make each maxout unit.
:param bias: If set to False, the layer will not learn an additive bias.
"""
@daskol
daskol / tty-size.c
Created April 4, 2019 13:28
Get size of console attached to stderr.
/**
* \file tty-size.c
* \brief Get size of console attached to stderr.
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>