Skip to content

Instantly share code, notes, and snippets.

@EderSantana
Last active August 29, 2015 14:17
Show Gist options
  • Save EderSantana/6d969169c0d7eddb6d0c to your computer and use it in GitHub Desktop.
Save EderSantana/6d969169c0d7eddb6d0c to your computer and use it in GitHub Desktop.
Conditioned Recurrent
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