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
class UnDef(): | |
pass | |
UNDEF = UnDef() | |
class Block(object): | |
def __getattribute__(self, name): | |
value = object.__getattribute__(self, name) | |
if value == UNDEF: |
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
# INTRODUCTION | |
# ------------ | |
# | |
# Bart's logistic regression oneliner has served us well | |
# forcing us to think how to make the framework | |
# suitable for quick-and-dirty experimentation with small | |
# standard models. It did not force us to think about | |
# scalability and flexibility necessary for big | |
# experiments with big models. | |
# |
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
import theano | |
from theano.tensor.shared_randomstreams import RandomStreams | |
r = RandomStreams(1) | |
y, u = theano.scan(lambda : r.binomial(size=(2, 2)), n_steps=3) | |
f = theano.function([], [y]) | |
# It still gives me three different sequence of random matrices! | |
print f() |
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
............/home/rizar/Dist/theano/theano/scan_module/scan_perform_ext.py:133: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility | |
from scan_perform.scan_perform import * | |
...ERROR (theano.gof.opt): SeqOptimizer apply <theano.gof.opt.EquilibriumOptimizer object at 0x4ac9c50> | |
ERROR (theano.gof.opt): Traceback: | |
ERROR (theano.gof.opt): Traceback (most recent call last): | |
File "/home/rizar/Dist/theano/theano/gof/opt.py", line 195, in apply | |
sub_prof = optimizer.optimize(fgraph) | |
File "/home/rizar/Dist/theano/theano/gof/opt.py", line 81, in optimize | |
ret = self.apply(fgraph, *args, **kwargs) | |
File "/home/rizar/Dist/theano/theano/gof/opt.py", line 1693, in apply |
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
import numpy | |
import theano | |
from theano import tensor | |
from theano.printing import debugprint | |
floatX = theano.config.floatX | |
foo_a, foo_x, r = 3 * [None] | |
def foo(x, a): |
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
class Data(object): | |
"""Super abstract class for all data sources. | |
So far does not have neither methods nor attributes, | |
but perhaps it can provide some sort-of signature, | |
e.g. channel names. | |
""" | |
pass |
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
class RecurrentWithFork(Initializable): | |
@lazy(allocation=['input_dim']) | |
def __init__(self, recurrent, input_dim, **kwargs): | |
super(RecurrentWithFork, self).__init__(**kwargs) | |
self.recurrent = recurrent | |
self.input_dim = input_dim | |
self.fork = Fork( | |
[name for name in self.recurrent.sequences | |
if name != 'mask'], |
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
# This to illustrate the idea how deep BiRNN will be implemented in Blocks. | |
class RecurrentWithFork(Initializable): | |
@lazy(allocation=['input_dim']) | |
def __init__(self, recurrent, input_dim, **kwargs): | |
super(RecurrentWithFork, self).__init__(**kwargs) | |
self.recurrent = recurrent | |
self.input_dim = input_dim | |
self.fork = Fork( |
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
seen = set() | |
def strip(obj): | |
if id(obj) in seen: | |
return | |
seen.add(id(obj)) | |
if isinstance(obj, theano.Variable): | |
obj.tag.annotations = [] | |
obj.tag.roles = [] | |
if isinstance(obj, (list, tuple, set)): | |
for el in obj: |
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
diff --git a/reverse_words/__init__.py b/reverse_words/__init__.py | |
index b649ab5..ac296e7 100644 | |
--- a/reverse_words/__init__.py | |
+++ b/reverse_words/__init__.py | |
@@ -14,7 +14,7 @@ from theano import tensor | |
from blocks.bricks import Tanh, Initializable | |
from blocks.bricks.base import application | |
from blocks.bricks.lookup import LookupTable | |
-from blocks.bricks.recurrent import SimpleRecurrent, Bidirectional | |
+from blocks.bricks.recurrent import SimpleRecurrent, LSTM, Bidirectional |
OlderNewer