# GNN (DGL) with Multi-Agent Reinforcement Learning

**URL:** <https://discuss.ray.io/t/gnn-dgl-with-multi-agent-reinforcement-learning/4567>\
**Category:** RLlib\
**Created:** [January 4, 2022, 12:08am UTC](https://discuss.ray.io/t/gnn-dgl-with-multi-agent-reinforcement-learning/4567 "2022-01-04T00:08:38Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Sertingolix](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sertingolix/32/649_2.png) [@Sertingolix](https://discuss.ray.io/u/Sertingolix)\
**Post date:** [January 5, 2022, 9:03am UTC](https://discuss.ray.io/t/gnn-dgl-with-multi-agent-reinforcement-learning/4567/4 "2022-01-05T09:03:19Z")

</div>

I found this post, where someone creates the graph in the model init method:

> [@Pytorch Geometric in RLLib?](https://discuss.ray.io/t/pytorch-geometric-in-rllib/3079/3):
>
> I use torch geometric in ray rllib here: [graph-conv-memory-paper/ray\_graph.py at master · smorad/graph-conv-memory-paper · GitHub](https://github.com/smorad/graph-conv-memory-paper/blob/master/src/models/ray_graph.py)

I use the observation approach:

In the obs space you can use:  
edges = Repeated(Box(low=0, high=N, shape=(2,), dtype=np.int64), max\_len=max\_edges)  
obs\_space = Dict({‘edges’:edges})

in the model use the unflattened observation  
edges = input\_dict[“obs”][‘edges’]

which is of type repeated\_values:

> <https://github.com/ray-project/ray/blob/61a1274619a83c5c53c0fd64f1362e2c5b2a8ca8/rllib/models/repeated_values.py>

Make sure your dimensions add up and don’t forget to cast the tensor if it’s needed. By default observations in the model are floating point numbers.

You can extend this for node embeddings

---

_[View the full topic](https://discuss.ray.io/t/gnn-dgl-with-multi-agent-reinforcement-learning/4567)._
