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

Contributing to Keras-Sharp #1

Open
mdabros opened this issue Jul 15, 2017 · 16 comments
Open

Contributing to Keras-Sharp #1

mdabros opened this issue Jul 15, 2017 · 16 comments

Comments

@mdabros
Copy link

mdabros commented Jul 15, 2017

@cesarsouza Great work starting keras-sharp. I will have a more in depth look at the code as soon as time permits and start contributing.

You have already mentioned a lot of todos and a plan of action in the [keras-sharp-thread-in-tensorflowsharp]migueldeicaza/TensorFlowSharp#75.

What is the procedure for contributing so several people don't start working on the same issue. Create an issue based on the todo list and create a corresponding pull request?

@cesarsouza
Copy link
Owner

cesarsouza commented Jul 15, 2017

Hi @mdabros,

Thanks for opening the issue. In my answer below I will re-write some of the points that I had mentioned in the TensorFlowSharp issue here, just to make it easier for others who will come to this issue later.

The way I see, there are at least two almost separate lines of work that can be followed: The Keras engine, and the TensorFlowSharp backend.

  1. For the Keras engine, my plan of action was to develop it in a structural-risk-minimization-style way:

    I had 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. I guess this set of tasks would be more fit for people with experience with Python, Keras and C# but not necessarily TensorFlow/ TenslorFlowSharp.

  2. For the TensorFlowSharp backend: If anybody wants to proceed this way, it should be possible to start replacing some of the placeholder code at TensorFlowBackend.cs even if there are no current examples/unit tests that exercises them. I believe this would require more knowledge about TensorFlowSharp than Keras.

In both cases, I would recommend doing just as you mention: open an issue here to signal you are going to work on the issue, then send a pull-request. If you are going to try to implement one of Keras examples, you can start by posting it in the issue tracker, so other people can realize what exactly you are trying to implement.

Also, please note that the code is quite far from complete, and is not respecting the standard C#/.NET style in many places, especially regarding encapsulation. However, I think it would be better to ignore those style/encapsulation issues now in the beginning until we get most of the Python translation right. We will come back at them later.

Regards,
Cesar

@gmlwns2000
Copy link

gmlwns2000 commented Jul 15, 2017

Hi guys.

Thank you for great starting @cesarsouza! I feel this project is good to work on. And so, I want to work on TensorFlowSharp backends.

And I have some opinion for developing roadmap.

First, I want to make this project as portable class library based on Xamarin.
Xamarin is wonderful toolkit to port and deploy c# application to everywhere. It increases accessibility of an application. (Code once, run everywhere. It's great!) So I think if keras on mobile, we could run amazing things on mobile too (inference, chatbot, and more deep learning tools) Also I already ported TensorFlowSharp to Xamarin (Win, Android, UWP).

Second, I am no idea to port python codes to c#, because I have no experience like that before. Does it line-by-line? I think line by line is the most convincing way as I think.

@mdabros
Copy link
Author

mdabros commented Jul 15, 2017

@cesarsouza thanks for outlining the contribution procedure and plan of action. This will surely help to focus the effort.

I like your approach for porting the Keras engine. I also think this is the fastest and safest way to get some examples up and running.

I will try to help where ever it makes the most sense, with the goal of getting the examples to work. I should have a couple of days of spare time in the near future.

I agree on functionality first and C# .Net style later.

I really hope this will take-off in a good way :-).

@cesarsouza
Copy link
Owner

Hi @gmlwns2000,

Thanks for the comment and willingness to help!

I hadn't explicitly considered Xamarin in the roadmap of this project, but one thing that surely has been considered and will be implemented at some point is compliance to .NET Standard. Would a .NET Standard library be usable from Xamarin? If yes, then I guess Xamarin will be definitely supported.

Regarding whether porting Python code on a line-by-line basis is possible, I would say it is quite feasible most of the time, even though sometimes we might have to get creative with LINQ. But most of the time it works (in the worst case, we can just write helper methods to accomplish the same effect as the python code. However, one thing that is surely difficult is to determine what is the most general type that a variable in Python is going to contain during runtime, so we can use the same type in C#. Another thing is to handle variables that change types, as it is common in Python when doing argument validation. However, those can be addressed by using some conventions (i.e. adopting a naming convention for variables that have already been validated inside a method, and whose type should not change anymore).

@mdabros thanks, my main goal right now is to try to get as most people as possible interested in the project. I will not be able to commit much in the next 1-2 weeks because of a CVPR, but will surely retake the work later. In the meantime, please do not hesitate to spread the word about the project.

Regards,
Cesar

@lobrien
Copy link
Contributor

lobrien commented Jul 29, 2017

Aloha,

Just wanted to say that within the Xamarin team at Microsoft, we're very interested in AI and tools that can help democratize the technology. Personally I'm a big fan of Keras and am excited by this project, although there's clearly a lot of work ahead!

If there is any help I can provide answering questions re. Xamarin technologies, Visual Studio for Mac, etc., please feel free to ask.

@cesarsouza
Copy link
Owner

cesarsouza commented Aug 1, 2017

Hi @lobrien,

Thanks a lot for the positive feedback! However, as you correctly stated, there's lots of work ahead!

Regarding Xamarin, as I might have mentioned before, though, I have to say that achieving Xamarin compatibility out-of-the-box is not a current target for the project. This is something that should come out naturally once all the foundation stones are laid out.

Well, since you mentioned you could answer questions regarding Xamarin, actually I have one question to ask: I do not have much experience with Xamarin, but does it, or is it going to, offer support for .NET Standard 2.0 libraries out-of-the-box? If that's the case then I guess we will also have it covered because this should be certainly in the roadmap for this project.

Regards,
Cesar

@cesarsouza
Copy link
Owner

Hi everyone,

I've just added some (crude) wiki page describing how one could contribute to the project by creating unit tests and making them pass.

I've started working on making the very first example pass (Issue #3), but so far I have already committed working examples to the following TensorFlow backend functions:

  • K.int_shape
  • K.ndim
  • K.random_normal
  • K.random_uniform
  • K.variable
  • K.zeros

If anybody would like to work in completing the TensorFlowSharp backends, please take a look at the wiki page I've just mentioned. Only a minimal knowledge of Python is necessary to complete those tasks.

Regards,
Cesar

@cesarsouza
Copy link
Owner

Hi everyone,

The first example unit test (Issue #3) is now passing, meaning that the basic execution flow for adding layers to a Sequential model should now be working. I am now adding more unit tests for other examples in the documentation.

By the way, if anybody who is willing to contribute would like some tips on how to port Python code from Keras, I just wanted to say that it is possible to install Keras (from git), TensorFlow (using pip3) and Spyder3 (from apt-get) in Bash for Windows 10.

Afterwards, if you have a X server/client also installed such as VcXsrv you will be able to launch Spyder3 and follow Keras' Python examples using a debugger, to see if the execution is indeed following the same code path.

Regards,
Cesar

cesarsouza added a commit that referenced this issue Aug 13, 2017
Updates GH-6: Implement the Flatten layer
Updates GH-5: Implement the Conv2D layer
Updates GH-4: Make the first example for the Sequential model pass
Updates GH-1: Contributing to Keras-Sharp
@cesarsouza
Copy link
Owner

Hi everyone,

Just to give an update: the basic layers, loss functions, weight initializers have already been implemented in Keras Sharp. However, before we are able to get a model to train, it might be necessary to solve migueldeicaza/TensorFlowSharp#25 first. If anyone would like to help solving that issue in TensorFlowSharp repository, please feel free to jump in!

Regards,
Cesar

@cesarsouza
Copy link
Owner

Currently blocked by tensorflow/tensorflow#13190

@cesarsouza
Copy link
Owner

Until the TensorFlow/TensorFlowSharp issues are fixed, I've started adding support for CNTK instead.

cesarsouza added a commit that referenced this issue Oct 3, 2017
 - Continuing to add support for training;
 - Adding more CNTK backend implementations;
 - Updates #1: Contributing to Keras-Sharp;
cesarsouza added a commit that referenced this issue Oct 4, 2017
@cesarsouza
Copy link
Owner

Hi everyone!

I just wanted to let you know that Keras# finally supports model training. There are a few issues (particular to TensorFlowSharp, CNTK, and even both) which are currently preventing more complex models from being trained right at this moment. However, since the main engine and most of the backend code for both CNTK and TensorFlow has already been ported, the project now allows users to train and evaluate MLPs - while it's certain that MLPs are no big deal for most machine learning frameworks right now, the main point is that those MLPs are being trained by a direct, line-by-line port of the Python Keras API into C#. This means we are currently supporting console status output, configurable metrics and switchable backends (for both CNTK and TensorFlow).

Even though only MLPs are supported for now, this update should serve as a validation that the main idea, i.e. bringing a line-by-line port of Keras to C#, is not only feasible, but it's one of the most extensibility-friendly routes that could have been adopted for development. Until a few days ago support for CNTK had barely been planned, but thanks to the knowledge laying in Keras-proven APIs, it could be added in almost no time.

If anyone is interested - please subscribe to (watch) the project's issue tracker for new issues. I will be adding new issues shortly describing areas that need further development, in order of priority.

Regards,
Cesar

@lydiae36
Copy link

Hello,
I'm try your project, but developer environment is not OK....
How to create developer environment step by setp?
ex: visual studio version? How to install Accord、Keras Sharp、Tensorflow Sharp、CNTK?

@cesarsouza
Copy link
Owner

Hi @lydiae36,

Thanks a lot for the comment! There is a page detailing how to contribute to the project in the wiki. I've just updated it to include also instructions about how to clone and build the project for the first time.

Hope it helps! If you find a problem following the instructions please let me know so I can update it!

Regards,
Cesar

@lydiae36
Copy link

lydiae36 commented Dec 1, 2017

Hi @cesarsouza

Development environment has been successfully created.
This is very helpful, thank you very much!
Written very detailed, very good!

In addition,
I want to use Keras-Sharp in Windows From
only Use the "hdf5" file to run predict
Is it estimated when will be completed "load_model" function?

@cesarsouza
Copy link
Owner

Hi @lydiae36,

Great! I am glad it has worked for you. Regarding the "load_model" function I am afraid it will take a bit more of time. Many operations are still not available in TensorFlow's C++ API and TensorFlowSharp yet (meaning they are a bit outside of my control at the moment).

However, if you could let me know which kind of model you are trying to implement, and if could provide me an example of the particular HDF5 file that you are trying to load into Keras#, I could start to shift development towards this goal and give more priority to this issue.

Regards,
Cesar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants