Skip to content

Instantly share code, notes, and snippets.

View bzamecnik's full-sized avatar

Bohumír Zámečník bzamecnik

View GitHub Profile
@bzamecnik
bzamecnik / example_outout.txt
Created October 11, 2017 12:34
Prints a list of messages from a MIDI file using the `mido` library
=== Track 0
<message note_on channel=0 note=69 velocity=100 time=0>
<message note_off channel=0 note=69 velocity=0 time=522>
<message note_on channel=0 note=71 velocity=100 time=27>
<message note_off channel=0 note=71 velocity=0 time=27>
<message note_on channel=0 note=69 velocity=100 time=27>
<message note_off channel=0 note=69 velocity=0 time=27>
<message note_on channel=0 note=71 velocity=100 time=27>
<message note_off channel=0 note=71 velocity=0 time=137>
<message note_on channel=0 note=72 velocity=100 time=27>
@bzamecnik
bzamecnik / TimeLimitedString.scala
Created October 10, 2017 20:45
Hack to limit execution time of java.util.regex.Pattern with catastrophic backtracking.
package com.github.bzamecnik.regex
import scala.concurrent.duration._
/**
* Wraps String to make its usage time limited.
*
* After given time duration charAt() operation will start throwing a
* TimeoutException.
*
@bzamecnik
bzamecnik / octopi_issue_net.txt
Created September 17, 2017 15:11
OctoPi /etc/issue.net - octopus ascii art from http://www.oocities.org/spunk1111/aquatic.htm
_ _ ___
___ ___| |_ ___ _ __ (_) .-' `'.
/ _ \ / __| __/ _ \| '_ \| | / \
| (_) | (__| || (_) | |_) | | | ;
\___/ \___|\__\___/| .__/|_| | | ___.--,
Raspbian |_| _.._ |0) ~ (0) | _.---'`__.-( (_.
GNU/Linux 7 __.--'`_.. '.__.\ '--. \_.-' ,.--'` `""`
( ,.--'` ',__ /./; ;, '.__.'` __
_`) ) .---.__.' / | |\ \__..--"" """--.,_
`---' .'.''-._.-'`_./ /\ '. \ _.-~~~````~~~-._`-.__.'
@bzamecnik
bzamecnik / building_tensorflow_with_avx.md
Created September 17, 2017 12:29
Building TensorFlow with AVX
@bzamecnik
bzamecnik / tf_feeding_shapes.py
Created August 11, 2017 14:45
TensorFlow - feeding & shapes
# Question: can we replicate https://github.com/rossumai/keras-multi-gpu/issues/2
# InvalidArgumentError: Shape [-1] has negative dimensions
# [[Node: replica_0_1/model_1_sample_weights = Placeholder[dtype=DT_FLOAT, shape=[?], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
import tensorflow as tf
a = tf.placeholder(dtype=tf.int8, shape=(None, None))
b = tf.placeholder(dtype=tf.int8, shape=(None, None))
c = tf.add(a, b)
@bzamecnik
bzamecnik / mnist_mlp_func_multigpu.py
Created August 4, 2017 02:51
Data-parallel SGD experiment - make_parallel() + MNIST MLP Keras 2
'''Trains a simple deep NN on the MNIST dataset.
Gets to 98.40% test accuracy after 20 epochs
(there is *a lot* of margin for parameter tuning).
2 seconds per epoch on a K520 GPU.
'''
from __future__ import print_function
import keras
@bzamecnik
bzamecnik / data_parallel_model.py
Last active August 9, 2017 13:03
Data-parallel model in Keras - a sketch (@rossumai)
import keras.backend as K
from keras.layers import Lambda
from keras.layers.merge import concatenate
from keras.models import Model
import keras.optimizers
from keras.optimizers import clip_norm, Optimizer
import tensorflow as tf
# this should be fairly ready
class DataParallelOptimizer(Optimizer):
@bzamecnik
bzamecnik / installing_cuda_gtx980ti_ubuntu_1604.md
Last active January 9, 2020 15:35
Installing CUDA 8.0 on PC with with GTX 980 Ti and Ubuntu 16.04

Installing CUDA 8.0 on PC with with GTX 980 Ti and Ubuntu 16.04

State as of 2017-07-31.

Recently I was installing CUDA on a Azure NC6 VM with Tesla K80 and later the same day I also upgraded my personal machine with GTX 980 Ti from Ubuntu 15.10 to 16.04 and completely reinstalled CUDA.

I had NVIDIA driver 361, CUDA 7.5 and cuDNN 4 or 5 and wanted CUDA 8.0

@bzamecnik
bzamecnik / mlok_banner.txt
Created July 31, 2017 13:50
MLok ASCII banner /etc/issue.net
_ _
_ __ ___ | | ___ | | __
| '_ ` _ \| |/ _ \| |/ /
| | | | | | | (_) | < 0--0^^^^^^^^^^^^\________
|_| |_| |_|_|\___/|_|\_\ \__/||-------||---------~
`` ``
@bzamecnik
bzamecnik / installing_cuda_on_azure_nc_tesla_k80_ubuntu.md
Last active January 18, 2022 21:13
Installing NVIDIA CUDA on Azure NC with Tesla K80 and Ubuntu 16.04