ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

Visualizing the neural network used by PPO Model

Open ghost opened this issue 7 years ago • 8 comments

Hi all, I am working on a project in Unity where my agent has two Cameras and 281 vector observations. To obtain a better understanding on what is going on I was wondering if it is possible to visualize the underlying architecture used by the PPO model? Unforunately, under graphs in Tensorboard I found this message "No graph definition files were found."

ghost avatar Apr 29 '19 13:04 ghost

Hi @Dreadnut93 -- this should be possible as the graph definitions are being saved when the model is output after training. I'm not sure where exactly Tensorboard needs the graph definition file to be located, but we'd welcome instructions or changes to make this process easier if you are able to make it work.

harperj avatar Apr 29 '19 18:04 harperj

Hi @harperj, here are the steps I used to plot the my graph.

1.) I copied the "import_pb_to_tensorboard.py " from (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/import_pb_to_tensorboard.py) to my ml-agents-master directory.

2.) Using anaconda to activate the ml-agents environment and navigated to the directory where the ML-Agents Toolkit is installed.

3.) From there I executed the following command

python import_pb_to_tensorboard.py --model_dir models\X\NewLearningBrain\raw_graph_def.pb --log_dir=summaries

If everything done correctly, the following message should appear "Model Imported. Visualize by running: tensorboard --logdir=summaries"

4.) Run tensorboard --logdir=summaries

Now, next to the Scalars there should be an option to select graphs.

5.) By double klicking on the “import” node one can see the full graph.

I hope it will be useful to somebody.

ghost avatar Apr 30 '19 08:04 ghost

Hi @Dreadnut93 - hope you are doing well. Thank you for raising this and providing instructions. We've added this as a potential enhancement for future versions of ML-Agents. In the meantime, would you be open to creating PR, for a single MD document, in our /docs folder from the develop branch that details these instructions?

Happy to do it as well, if you are busy and cannot make the contribution at this time.

shihzy avatar Apr 30 '19 15:04 shihzy

Hi @unityjeffrey, is there a deadline for the task? I would do it gladly, but it may take some time.

ghost avatar May 02 '19 08:05 ghost

hi @Dreadnut93 - no deadline. happy to write it up for you as well. let me know. thanks!

shihzy avatar May 02 '19 14:05 shihzy

To see the computation graph, I initialized summary_writer as : self.summary_writer = tf.summary.FileWriter(self.summary_path, self.policy.sess.graph)

MengqiYe avatar May 05 '19 08:05 MengqiYe

I logged a feature request in our internal tracker to automatically save the graph for Tensorboard. Closing this issue for now, but please reopen (or make a new one) if you have more problems.

chriselion avatar Sep 24 '19 22:09 chriselion

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[bot] avatar Jan 29 '21 14:01 github-actions[bot]