Skip to content
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

[FeatureRequest] Option to set model callback at any time #270

Closed
rychuelektryk opened this issue Oct 30, 2021 · 4 comments · Fixed by #332
Closed

[FeatureRequest] Option to set model callback at any time #270

rychuelektryk opened this issue Oct 30, 2021 · 4 comments · Fixed by #332
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@rychuelektryk
Copy link

rychuelektryk commented Oct 30, 2021

Hi,

Right now you can only set callback when compiling model. Can you add option to set callback independently to compilation? Alternatively maybe fit method could accept callback?

My case:
I have a kfold evaluation method which accepts already compiled Functional model as a parameter. During fit I want to analyse whether to stop early due to overfitting. In order to do that I need to analyse model callbacks. It would be great if I could set my callback inside my kfold evaluation method on already compiled model.

@zaleslaw zaleslaw added the enhancement New feature or request label Nov 1, 2021
@zaleslaw zaleslaw added this to the 0.4 milestone Nov 1, 2021
@zaleslaw
Copy link
Collaborator

zaleslaw commented Nov 1, 2021

Let's discuss your proposal and how it can be implemented in your application.
Do you need 1 callback per model or do you need a few callbacks per model?
Do you want to use different callbacks: for the training and evaluation phase or probably for the prediction phase?

What if the existing Callback field will be converted from protected to public, does it solve the existing problem?

@zaleslaw
Copy link
Collaborator

@rychuelektryk could you please comment on this thread?

@rychuelektryk
Copy link
Author

rychuelektryk commented Nov 10, 2021

Hi @zaleslaw , and sorry for late response

I think that from architectural point of view passing callback at compile stage is at least inconvenient. Model compilation can be located in very different place in code than fit/predict/evaluate. The need for listening for fit/predict/evaluate events probably emerges somewhere around calls to fit/predict/evaluate methods and I feel that it would be most natural to pass dedicated callbacks(FitCallback, PredictCallback, EvaluateCallback) as last parameter to invocation of those methods. So in this approach there would be one callback per invocation.

Sorry that my current proposition is different than what I initially requested creating this thread.

@zaleslaw
Copy link
Collaborator

So, I don't see any objection to applying this principle of different callbacks after compilation, it's interesting to see how the KFold is implemented with KotlinDL and probably it will be added in the future release of KotlinDL in the next few months (and probably will be available in early alpha versions of the framework)

I'll fix this issue and hope to get a feedback from you about implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants