-
Notifications
You must be signed in to change notification settings - Fork 124
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
Keras Callback #13
Comments
Thanks for the appreciation. Are you trying to build a custom callback? Could you please let me know what the callback function will do so that I can try to implement it or provide you solution? |
Yes I try to build a custom callback! I want to get the step, batch, training and validation score value - let’s say in a Console.WriteLine output. How can I do it? |
Any Ideas on how to make a delegate for example on_batch_end or on_train_begin? |
Didn't get much time last few weeks, will try to come up with an example for your requirement by this week |
I am able to come up with a solution to implement custom callback. Since the library is a wrapper for the Keras python, the custom callback need to be a python code only. Here it the example: https://github.com/SciSharp/Keras.NET/blob/master/Examples/BasicSamples/ImplementCallback.cs Steps1: Create a python file with your callback implementaion.Took an example from keras documentation itself:
Step2: In your .NET project use the Calback.Custom method which can take the file or code to give you instance of callback object. Pass the callback instance to fit method. You can access the custom properties defined in the python implementation:
|
Please reopen if still need help |
Thanks for the example! This helps me a lot! Is there a way to create a delegate method that fires on every training step in C# ? |
Since most of the core functionality is written in python and Keras.NET invoke those functions, so its not possible to hook .NET delegates within Python. |
Ok! Thank you! |
Hi!
Your project is very useful and I appreciate your contribution! I started with the example and wanted to customize the Keras Callback mechanism to show the model.fit progress to the user.
But I don't really know how to do it:
Declaring a new class
private class KerasCallback : Keras.Callbacks.Callback{}
Creating the object:
KerasCallback x1 = new KerasCallback();
And then send to fit:
model.Fit(x, y, batch_size: 2, epochs: 1000, verbose: 1, callbacks: new Callback[] { x1 });
And all I get is:
Python.Runtime.PythonException: AttributeError - Callback object has no attribute Invoke.
It seems as I missed to declare a method or property to the class. Any ideas?
Maybe you could extend one of the examples with the solution.
Thanks in advance!
The text was updated successfully, but these errors were encountered: