-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Implement Neural Networks and Reinforcement Learning Modules #2506
Comments
In this case, it should remain a GDNative plugin to not bloat the core with a feature most developers won't use 🙂 Machine learning libraries are rarely compact in terms of binary size, so we need to be careful about what goes into core Godot. |
So this should be closed then? Or should the GDNative plugin be discussed here? |
IIRC we had a proposal to do with NN already? So most likely it can be closed... |
This repository is designed to discuss features that should be maintained officially. While GDNative add-ons can be official (example), I doubt we'll take on the task of maintaining bindings for a machine learning library ourselves. The community will likely scale better for such tasks. |
There is no rush to close proposals, unless you can point for a direct duplicate or they don't follow the template at all. Even failing to satisfy the "can't be done as an addon" rule is not a sign to immediatelly close it. Besides, we were asked recently to keep proposal open for a minimal time. 🙂 |
I createed a GDNative library for neural network and there is youtube tutorial for that |
@mohsenph69 Nice, i'll check it out. Also which library did you use to implement the neural network architecture, or was it built from scratch? |
The two approaches that work today are:
(note that my tensorflow-lite godot module isn't maintained.) |
This was previously discussed in godotengine/godot#30613 (see also #1577). It depends on user support and developer base. If this approach becomes mainstream for implementing AI-like behavior, then this proposal will become more relevant in the future. But yeah I kind of doubt that Godot would have this out of the box in either case, unless reduz would want to delve into this topic himself. 🙂 |
I'm making a simple 8x8 board game, single player vs single cpu character + some other entities like bombs, hearts, etc. For starters, I've collected the (input, output) data by bruteforcing the cpu character to do random moves and selecting the ones that yield benefits for said character. After that I designed a sequential model using python and keras which uses only Dense layers so I could collect the weights and biases once the model is trained to eventually run them through a simple forward pass algorithm inside Godot. And here is where my problems started. After hours & hours of training, reading and studying I've finally realized that I actually need to use Conv2D nets instead of just plain Dense sequential layers to achieve more than ~78% accuracy. A forward dense layer is easy to implement in Godot (it's just basic linear algebra after all) but Conv2D networks are a totally different beast. I'm still trying different configurations and figuring out ways to use just plain Dense layers with a sequential model but I'm definitely running out of options here. Here the deal: I don't really need to train anything inside godot, the frameworks are doing all the heavy lifting in my case, but I definitely, desperately need an advanced library to run predictions, that's it. |
Hi all,
During that time, godot competitors did not wait. In 2017, Unity officially released 'Barracuda', the 'Unity-Inference-Engine', to at least run inference on a NN in the official Unity : I suppose some, not understanding the domain are perhaps just afraid of adding a new huge risky dependency to Godot core. If so, let's just remind what @postmortem-x has just confirmed :
Kind regards Ref: an example of application which just needs to be able to infer a simple 10KB linear NN : the eigen Tensor class, core of TF: the ATen Tensor class, core of pytorch: |
I'm developing a framework (with visual appeal) that has the features you suggest: https://github.com/gilcoder/ai4u. |
I have been reading up on the numerous requests for NN inference inside Godot. |
@gilcoder @Xrayez We work as a team recently at Microsoft Hackathon and we combine the best of both worlds e.g. PyTorch training involving Gym ( OpenAI RL) & Godot Physics engine environment and THEN export the trained model to ONNX format for consumption using c# in Godot . It is a straight forward to use GDScript to call the c# wrapper of ONNX directly all within Godot without involving python server. => Here is the link to Godot ML Agent repo |
This seems to be an interesting .NET Reinforcement Learning library potable to Godot |
I am currently evaluating https://catboost.ai/ for non deep learning machine learning and OpenVINO https://docs.openvino.ai/latest/index.html for deep learning. If anyone was interested, contact me. |
@csstej You posted in March, Have you found Unity ML Agent-like solution for Godot? Here we provide a (possible) WORKFLOW for Godot which is very similar how Unity ML agent train and deploy RL agent. What need to be done NEXT!!
Why? How important to Godot community? The path to Godot option for users to do similar things like Unity ML Agent will still take many months, if not years. If the Godot community can come together to do the What need to be done NEXT!! to make Godot a viable option, we will be reduce the time to perhaps less than 6 months (especially now there is a WIP workflow (as approach as Unity ML Agent => using the same MIT license RL python library)) @fire => You are absolutely right with your assessment . Now the community need to come together to TRAIN and DEPLOY Unity ML Agent like solutions ====> ALL within Godot |
I built a small addon for TensorFlow inference in Godot available here. Currently, only built for and tested on macOS. The README includes instructions for building from source and I'd welcome any PRs targeting other platforms. |
ML-Agents has its merits, but I believe it has a wrong design. At the current stage of DRL in games, which is very experimental, Barracuda is very limited. For example, try getting the return of the state value estimate function and you'll find it's not easy if you try to incorporate that into the agent logic in C#. It is difficult to get any customization of the neural network that goes a little beyond the traditional feature-extractor --> dense/lstm/gru layers --> output layers. Trying to achieve compatibility with MLAgents is limiting yourself. DRL isn't as mature as to be boxed in as the Unity folks seem to think. |
I stopped messing around with Godot for a while, mainly because I have a project running in Unity and I have little time to deviate from that path. |
@gilcoder I read what you have written. I try once more to understand ai4u.
So the case is close for you. |
|
Thx, now I get it. I tend to get second opinion beyond one source. When bringing ideas from different sources, that is when I understand and learn. |
I posted a standalone ONNX prototype of https://github.com/V-Sekai-fire/ML_fire_juan_mosaic that load ONNX model "filters". The unfinished design is to use operating system native GPU drivers and put into a GDExtension or a Godot Engine C++ module.
|
Describe the project you are working on
Trying to implement a basic Artificial Neural Network in gdscript.
Describe the problem or limitation you are having in your project
Implementing a neural network from scratch can be tiresome and lead to bugs which can be complicated to track, also neural networks are best implemented in c++ using gdnative, but the implementation complexity stays the same.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Using mlpack Library (BSD License), which already has implementations of all the basic Machine learning Algorithms, Deep Learning Architectures and Reinforcement Learning models and implementing them by Binding this library to Godot.
For example, in a library like Tensorflow, creating a neural network can be done in a few lines of python code like:
which creates a basic neural network.
The main reason for this proposal is to make AI in games easier with less code, even for someone who isn't experienced in reinforcement learning algorithms or neural network models can use this module. By creating bindings in gdscript, it should be able to create an abstraction layer, so beginners should have just the basic understanding (ignoring the math), and be able to create AI at ease!
This library could also be implemented as a GDNative plugin.
Also this feature could not only be useful for game developers but also Researchers, Data Scientists and ML engineers, who would like to test out their work in an isolated environment. eg: Testing out an algorithm for a self driving car, Robotics etc;
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Implementation of Neural Network Regression using the mlpack library.
After Binding the module to godot using it in gdscript should closely resemble that of python from the tensorflow example,
(pseudo-code):
The Algorithms can be implemented either as a node or a Resource.
Training multiple agents like in unity's ml agents:
If this enhancement will not be used often, can it be worked around with a few lines of script?
Can't be implement in a few lines of code.
Is there a reason why this should be core and not an add-on in the asset library?
From the reasons stated above.
The text was updated successfully, but these errors were encountered: