This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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') |