Last active
August 29, 2015 14:17
-
-
Save EderSantana/6d969169c0d7eddb6d0c to your computer and use it in GitHub Desktop.
Conditioned Recurrent
This file contains 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 ConditionedRecurrent(BaseRecurrent): | |
def __init__(self, wrapped, **kwargs): | |
super(ConditionedRecurrent, self).__init__(**kwargs) | |
self.wrapped = wrapped | |
self.children=[wrapped] | |
def get_dim(self, name): | |
if name == 'context': | |
return self.wrapped.get_dim('inputs') | |
return self.wrapped.get_dim(name) | |
@application(contexts=['context']) | |
def apply(self, **kwargs): | |
context = kwargs['context'] | |
kwargs['inputs'] += context | |
for context in ConditionedRecurrent.apply.contexts: | |
kwargs.pop(context) | |
return self.wrapped.apply(**kwargs) | |
@apply.delegate | |
def apply_delegate(self): | |
return self.wrapped.apply |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment