Skip to content

Instantly share code, notes, and snippets.

@cancan101
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cancan101/07d03584a5fd66cec5c5 to your computer and use it in GitHub Desktop.
Save cancan101/07d03584a5fd66cec5c5 to your computer and use it in GitHub Desktop.
diff --git a/nolearn/lasagne.py b/nolearn/lasagne.py
index 5c2c64c..86f2e7a 100644
--- a/nolearn/lasagne.py
+++ b/nolearn/lasagne.py
@@ -22,7 +22,21 @@ from theano import tensor as T
class _list(list):
- pass
+ def set_params(self, **params):
+ # see: https://github.com/scikit-learn/scikit-learn/blob/c453711bc6cc5e759ab250d3bc6677e6641fd186/sklearn/base.py#L242
+ for key, v in params.iteritems():
+ split = key.split('__', 1)
+ if len(split) > 1:
+ # nested objects case
+ name, sub_name = split
+ for ln,l in self:
+ if ln == name:
+ l.set_params(**{sub_name: v}) # We assume that l is some wrapper of the layer + params
+ break
+ else:
+ assert False
+ else:
+ assert False
+ return self
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment