-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callbacks don't work when passed unitialized #14
Comments
I couldn't reproduce it:
Was this accidentally fixed? |
Okay, this is how to reproduce it:
|
That problem cannot be easiliy fixed it seems. We could not return Specifically, the problem occurs on all attributes that are un-initialized and have the I believe this is one further argument in favor of requiring everything to be initialized (see #13 ) |
Agree |
Came here to report the same bug. Doesn't passing callbacks initialized break sklearn compatibility ? the inner state of the callbacks will change during training, which contradicts: A workaround to this could be to store the uninstancied callbacks in a special container that inherits from lists ? class CallbackContainer(list): (I quickly checked that this does preserve This is still a slight modification of the input argument but it seems acceptable. |
Thanks for chiming in.
I don't think that skorch callbacks violate this the way they are implemented. It is true that they change their state and it is also true that this mutates the initial arguments. However, once training starts again or the network is initialized the callbacks are re-set to their initial state exactly the way they were initalized (via the In my problem there is no issue but maybe I'm overlooking something. Is there a particular reason that you are reporting this right now? |
Just to add to @githubnemo's comment, think of For that reason, I would leave the restriction except if you can show us a situation where this is undesired. |
Thank you for the clarification, I understand your points. I think it is debatable whether this is compatible with the sklearn coding guidelines or not. I'd like to add a few more remarks including my usecases. Before that, the issue for me is not strictly that the current
except I see two practical issues with instanciated callbacks passed as arguments:
(On a side not, speaking of references to old objects that should be flushed, it is not good to store a reference to the optimizer in LR schedulers like |
As you already said, this is not about callbacks being uninitialized but rather about potential side-effects.
I agree with you that storing references is problematic and should be avoided when possible. In this case, |
For example:
Error:
Probable cause:
get_params
recursively inspects all attributes of the wrapper instance includingself.callbacks
which still contains the uninitialized callbacks. It then callsget_params
which does not work as it is not a static method.The text was updated successfully, but these errors were encountered: