-
Notifications
You must be signed in to change notification settings - Fork 574
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
SampleTest.NearestNeighbor is loading data incorrectly #75
Comments
Hi Miguel, If I understood correctly, do you believe the problem is in the MNIST parser code at https://github.com/migueldeicaza/TensorFlowSharp/blob/master/Learn/Datasets/MNIST.cs ? If this is the case, I have also implemented a MNIST parser that you can find it here: https://github.com/accord-net/framework/blob/development/Sources/Accord.IO/IdxReader.cs I had originally written it under the LGPL but I can relicense it to TensorFlowSharp under MIT or any other license you might need. I will try to use to load the data in the kNN sample application and check if it works better. |
@cesarsouza Welcome! I hope you see that we are gathering help from different communitiess to make .NET deep learning a common phenomenon. |
@cesarsouza Thanks for reaching out - I do not recall the details, but I spend a couple of evenings comparing the different outputs (with small data sets) and could not found the culprit, everything looks ok. It might be the MNIST loader, would love if you could try your loader and see if that is the source of the issue, I suspected that. |
@cesarsouza I shared with you my KerasSharp port, it is not complete by any means, but it shows the work in progress. One problem is that I had not quite grasped that Keras is not intended to be a framework, it optimizes for ease-of-use, and when I started my effort, I was going for "framework". So some code can be simplified |
@migueldeicaza First off, thanks for your big efforts in starting a .net wrapping of tensorflow. I have been working on my own humble machine learning library, SharpLearning, for the last few years, trying to make machine learning more accessible to .net developers. This library also contains a project for neural nets and deep learning with a Keras-like interface. Like many others, I also see a great opportunity in using TensorFlowSharp as a provider of deep learning and other machine learning algorithms for .net. So I would very much like to contribute in porting some of the higher level concepts from the Python parts of tensorflow. Especailly the optimizers from python/tf/train and the python/layers, so we can start creating some examples that shows how to train neural nets using TensorFlowSharp. Is there any coordination on this part of the porting yet? |
@mdabros I already put SharpLearning on this discussion |
Hi @migueldeicaza, (Well, first of all sorry for the long delay before I could give a proper reply to your post) Thanks a bunch for sharing your KerasSharp port with me - I had taken a look on it a few days ago and I have to say, I completely understood what you meant when you said you were going for a "framework" type of project. In this way, I have to say that the idea I had for a KerasSharp project was a bit different. My intention was to do an actual, complete, line-by-line port of the Keras library to C# - meaning achieving an almost line-by-line translation of the current Keras python code including the abstraction flayers or different tensor processing frameworks which for me would be one of the most critical feature to have so far. I have at least three reasons for wanting a true, line-by-line port rather than a new similar project that happens to share a similar name, which I hope I will be able to explain below:
All this said, I want to disclose that I have also gone through most of Keras python codebase and have manually converted about 90% of the Python code into C# - although I recognize that there is still a long, long way until all this code could be actually usable. My initial plan was to be able to commit a compilable version of this initial repository to GitHub before the CVPR conference starts next week, but given my lack of free time, I might have to settle with an initial version filled with NotImplementedException placeholders. PS: By the way, if any C#/.NET fans also attending CVPR in end of next week would like to discuss the current state of deep learning in C#/.NET, please let me know, as I am not sure we are many these days. Regards, |
@cesarsouza I apologize if I am intruding in your discussion, but a direct port of Keras to C#/.Net would be great, and I think you are spot on with your observations.
If you have already ported 90% of the Keras codebase, then please put it on github, and if you accept contributions, I will be happy to contribute. I am not attending CVPR, but a discussion on the current state of deep learning in C#/.Net would have been great. I will be at NIPS this december, in case anybody is attending, and want to continue the discussion. |
Hi everyone, Thanks for the all feedback. I just wanted to say that I have finally put my version of a "Keras-Sharp" project on GitHub. It is also not complete just like @migueldeicaza's version, but most of the classes related to the engine of Keras are already there (but not necessarily tested). Most of my work was actually in trying to get the types right in all method calls, given that in Python things can change types at the blink of an eye. For example, here is the current status of the implementation for Sequential, Model, and Container classes which by far are one of the most complex in Keras:
Most of the activation functions, constraints, weight initializers, regularizers, losses have been ported (some still have NotImplementedException placeholders):
For now, the only optimizer with a partial implementation is SGD: And besides the interface being already defined, most of the implementation of the TensorFlowBackend is still empty: Of course, contributions are more than welcome. My plan of action was to develop it in a structural risk minimization-style:
I've marked the Keras commit I used as a base when converting the code above in a README.txt in the project's source folder. In order to make a test pass, it should be possible to go back to that commit and locate the Python code that should had been implemented by the code sections being covered by the test and check where they don't match. Additionally, another way to contribute would be to go gradually filling the TensorFlowBackend class with calls to TensorFlowSharp. Hope this can be useful. Regards, |
Ops, actually I apologize to @migueldeicaza because we completely diverged from the original topic of this issue, which is about SampleTest.NearestNeighbor and had nothing to do with Keras Sharp. Let's please not diverge further and continue the discussion somewhere else, if desired. |
Any updates here? If there is an issue with the MNIST loader, I haven't found it. Not sure if its anything, but I have noticed that nn_index has been converging to 1/4 of trainCount. |
Andrew Violette emailed me a pointer to the fix! It is embarrassing. |
…oader not working correctly - was copying byte sized blocks, not float-sized blocks
I have isolated the code to do the operations and they look fine with small data sets, I suspect my data loader is wrong.
For reference, this is a port of this sample:
https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/nearest_neighbor.py
The text was updated successfully, but these errors were encountered: