Skip to content

Instantly share code, notes, and snippets.

View kudkudak's full-sized avatar
😃

Stanislaw Jastrzebski kudkudak

😃
View GitHub Profile
@alimuldal
alimuldal / test_numpy.py
Last active April 5, 2020 10:25
test script for numpy BLAS linkage
#!/usr/bin/env python
import numpy
from numpy.distutils.system_info import get_info
import sys
import timeit
print("version: %s" % numpy.__version__)
print("maxint: %i\n" % sys.maxsize)
info = get_info('blas_opt')
from lasagne.layers import Layer
class HighwayLayer(Layer):
def __init__(self, incoming, layer_class, gate_nonlinearity=None,
**kwargs):
super(HighwayLayer, self).__init__(incoming)
self.H_layer = layer_class(incoming, **kwargs)
if gate_nonlinearity:
@kudkudak
kudkudak / conditional_entropy.ipynb
Last active February 3, 2016 13:33
Conditional entropy calculation in Python, Numba and Cython (ugly! sorry)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@udibr
udibr / beamsearch.py
Last active October 4, 2021 11:50
beam search for Keras RNN
# variation to https://github.com/ryankiros/skip-thoughts/blob/master/decoding/search.py
def keras_rnn_predict(samples, empty=empty, rnn_model=model, maxlen=maxlen):
"""for every sample, calculate probability for every possible label
you need to supply your RNN model and maxlen - the length of sequences it can handle
"""
data = sequence.pad_sequences(samples, maxlen=maxlen, value=empty)
return rnn_model.predict(data, verbose=0)
def beamsearch(predict=keras_rnn_predict,
@dwf
dwf / lib.py
Last active December 20, 2016 00:45
Minimal examples of using the Blocks MainLoop and checkpointing machinery.
# It's important not to define any classes you want serialized in
# the script you're running as pickle doesn't like that (if you pass
# save_main_loop=False to Checkpoint it's fine, though).
from theano import tensor
import numpy
import theano
from picklable_itertools import imap, izip, repeat
# Your algorithm object just needs two required methods: initialize()