Last active
August 29, 2015 14:12
-
-
Save cancan101/07d03584a5fd66cec5c5 to your computer and use it in GitHub Desktop.
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/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