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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I create a custom neural network in TensorFlow and run as an external brain? #696

Closed
RyanRizzo96 opened this issue Apr 28, 2018 · 13 comments
Assignees
Labels
help-wanted Issue contains request for help or information.

Comments

@RyanRizzo96
Copy link

RyanRizzo96 commented Apr 28, 2018

Hi everyone,

I have completed all the necessary steps to install ML-Agents on Windows 10 following this excellent tutorial:

https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Installation-Windows.md 馃憤

Next I followed this comprehensive guide to get started with the balance ball project. All has worked well.

Now, I want to go a step further and create not just my own new scenes and environments but also create the neural networks in Python. Since v 0.3 has done away with the PPO.ipynb file which I could edit and run the code in Jupyter notebook, I am stuck as to where I can actually code my custom neural network using Python and TensorFlow to use this as an external brain to my agent.

    1. Is it possible to create a custom neural network using Python and TensorFlow and somehow attach this as an external brain to my agent?
    1. Which file should I edit to start coding my custom neural network?
  1. Is this necessary from my side to build a neural network from scratch, or does unity ML-Agents provide all the coverage needed?
  2. Is it possible to create a custom neural network using Python and TensorFlow and somehow attach this as an external brain to my agent?
  3. Which file should I edit to start coding my custom neural network?
  4. Is this necessary from my side to build a neural network from scratch, or does unity ML-Agents provide all the coverage needed?

To give you a broader view of what I am trying to accomplish. I have a small robotic system modeled in unity to include friction coefficients and servo motor PID tuning to mimic a real-life robotic system. I now want to train this system using TensorFlow and Python by coding up a recurrent neural network. I was wondering whether this would be the way to go, since machine learning in Python and TensorFlow is 'easier' than in C#.

I cam across the Training ML-Agents documentation, but I am not talking about simply editing the config file training_config.yaml, but rather building a neural network from scratch.

In short I am looking to alter the Python API.

image

I could not seem to find any information regarding the above two points and have been stuck trying to figure this out. Any help would be greatly appreciated.

Thanks!

@xiaomaogy xiaomaogy added the help-wanted Issue contains request for help or information. label Apr 30, 2018
@joaquines
Copy link

yes you can. all the python code that creates the TF layers is included. you do not need to touch it for it to work, but if might be a good place to start if you want a custom topology.
Take a look at https://github.com/Unity-Technologies/ml-agents/blob/master/python/unitytrainers/models.py#L162

@mmattar
Copy link

mmattar commented Jun 5, 2018

Hi @joaquines - are you still facing any issues?

@xiaomaogy
Copy link
Contributor

Thanks for reaching out to us. Hopefully you were able to resolve your issue. We are closing this due to inactivity, but if you need additional assistance, feel free to reopen the issue.

@UgurUysal86
Copy link

Is it possible to use keras-rl in combination with ML-agents? I would like to create custom networks. Thank you.

@xiaomaogy
Copy link
Contributor

xiaomaogy commented Jun 19, 2019

@UgurUysal86 You can of course write your own trainer code and not use our trainer code at all.

@UgurUysal86
Copy link

Thank you! Is there any guide on how to create your own trainer?

@xiaomaogy
Copy link
Contributor

Emm....@UgurUysal86 if you don't know how to do that, then a guide won't help you much.

@UgurUysal86
Copy link

Ouch. Thank you anyway.

@MarkTension
Copy link

yes you can. all the python code that creates the TF layers is included. you do not need to touch it for it to work, but if might be a good place to start if you want a custom topology.
Take a look at https://github.com/Unity-Technologies/ml-agents/blob/master/python/unitytrainers/models.py#L162

This link would be helpful to me, but is broken, any new address to get here? Thanks!

@preston-willis
Copy link

preston-willis commented Nov 18, 2019

yes you can. all the python code that creates the TF layers is included. you do not need to touch it for it to work, but if might be a good place to start if you want a custom topology.
Take a look at https://github.com/Unity-Technologies/ml-agents/blob/master/python/unitytrainers/models.py#L162

This link would be helpful to me, but is broken, any new address to get here? Thanks!

Here you go: https://github.com/Unity-Technologies/ml-agents/blob/master/ml-agents/mlagents/trainers/models.py

Please tell me if you figure anything out. I'm trying to do the same thing.

@MarkTension
Copy link

Thanks! Will get back at you when I get it working for me

@preston-willis
Copy link

preston-willis commented Nov 19, 2019

Thanks! Will get back at you when I get it working for me

I just got it working. Since there isn't any documentation for the latest version, I downgraded to unity 2018.1.0. From there, I just followed this medium article and created my own academy, brain, and agent. I also created my own script to interface with the environment python/genetic_algorithm.py since I don't want to use RL.

Here is all my code:
https://github.com/iamPres/Bipedal-Walker

Hope this helps

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help-wanted Issue contains request for help or information.
Projects
None yet
Development

No branches or pull requests

8 participants