# Deeplearning in UE5 ?

**URL:** <https://forums.unrealengine.com/t/deeplearning-in-ue5/814046>\
**Category:** AI\
**Tags:** unreal-engine, question\
**Created:** [March 23, 2023, 11:53pm UTC](https://forums.unrealengine.com/t/deeplearning-in-ue5/814046 "2023-03-23T23:53:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![curemilkyway](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@curemilkyway](https://forums.unrealengine.com/u/curemilkyway)\
**Post date:** [March 23, 2023, 11:53pm UTC](https://forums.unrealengine.com/t/deeplearning-in-ue5/814046/1 "2023-03-23T23:53:56Z")

</div>

Hi all,

I want to train a AI players by reinforcement learning, I found that there are two plugins in UE5, ML Adapter and Python Editor Script Plugin, both them have no documentation or demo.

For ML Adapter, I only see that it is using the rpc interface to connect to phyton, I have no idea about how to use about rpc, what should i do in UE5 editor and python.

For Python Editor Script Plugin, does it same as link the libtorch library? I have experience in pytorch, but I don’t know how to use this plugin in UE5 c++ programming.

Thanks for any answers!

---

<div class="post-metadata">

**Author:** ![user\_737c76014ac88a883426eb75e10ec764e742e522218f23639c118d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@user\_737c76014ac88a883426eb75e10ec764e742e522218f23639c118d](https://forums.unrealengine.com/u/user_737c76014ac88a883426eb75e10ec764e742e522218f23639c118d)\
**Post date:** [December 6, 2024, 2:14pm UTC](https://forums.unrealengine.com/t/deeplearning-in-ue5/814046/2 "2024-12-06T14:14:40Z")

</div>

wanna to know too

---

<div class="post-metadata">

**Author:** ![Mitch\_Mitchell](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mitch_mitchell/32/909094_2.png) [@Mitch\_Mitchell](https://forums.unrealengine.com/u/Mitch_Mitchell)\
**Post date:** [December 6, 2024, 2:56pm UTC](https://forums.unrealengine.com/t/deeplearning-in-ue5/814046/3 "2024-12-06T14:56:27Z")

</div>

> [@curemilkyway](#):
>
> I want to train a AI players by reinforcement learning, I found that there are two plugins in UE5, ML Adapter and Python Editor Script Plugin, both them have no documentation or demo.
> 
> For ML Adapter, I only see that it is using the rpc interface to connect to phyton, I have no idea about how to use about rpc, what should i do in UE5 editor and python.
> 
> For Python Editor Script Plugin, does it same as link the libtorch library? I have experience in pytorch, but I don’t know how to use this plugin in UE5 c++ programming.
> 
> Thanks for any answers!

Reinforcement learning in Unreal Engine 5 (UE5) can be quite a challenging and complex task, especially when it comes to utilizing the available tools and plugins such as the ML Adapter and the Python Editor Script Plugin. I’ll try to provide some insights and potential approaches for getting started with both.

### 1. ML Adapter Plugin

The **ML Adapter Plugin** in UE5 is a new feature designed to integrate machine learning into Unreal Engine workflows, often used to train AI players through reinforcement learning by connecting the engine to external learning environments.

Currently, documentation for ML Adapter is quite sparse, but I can give you some directions based on the purpose of the plugin:

- **RPC Communication** :

### 2. Python Editor Script Plugin

The **Python Editor Script Plugin** allows for automation and scripting within UE5 using Python, but it serves a different purpose compared to reinforcement learning directly. This plugin is primarily for controlling editor-level tasks, modifying assets, etc., rather than directly integrating reinforcement learning models. Here’s some clarification:

- **Editor Automation** : This plugin is more about automating repetitive tasks in the editor, such as batch renaming assets, procedural generation, and automating setup.
- **Not Directly Libtorch** : The Python Editor Script Plugin does **not** provide direct functionality akin to linking to the `libtorch` library. It cannot inherently run PyTorch models in real time during gameplay. You might be able to script asset preparation, set up environments, or configure certain behaviors using Python, but it’s not the same as running PyTorch code during gameplay.

If you want to use **PyTorch** to train agents in a similar way to `libtorch`:

- You’ll have to create your Python training script using PyTorch, and then when you’re ready to integrate the model, you’d export the trained model into a format that can be used in UE5.
- **Libtorch Integration** : If you’re experienced in PyTorch, using **libtorch** is a reasonable approach to run neural networks inside C++ code in UE5. This involves including `libtorch` in your UE5 C++ project, and then you can use your trained PyTorch models for inference. It requires proper linking of `libtorch` to your C++ project, which can be somewhat complex, but it provides a direct way to run neural network inference within Unreal.

### Suggested Approach to Get Started:

1. **Simplified Testing** :

2. **RPC and ML Adapter Setup** :

3. **Using ML Adapter** :

4. **Python Editor Script Plugin** :

5. **Libtorch for Real-time Integration** :

6. **Learning Resources** :

#### Additional Considerations:

- **Model Update and Training Loop** : Reinforcement learning typically involves frequent updates to the model. Make sure that UE5 provides easy ways to get observations and make actions in an efficient manner.
- **Custom C++ Plugin** : It could be worthwhile to consider creating your own C++ plugin if you need more control over the communication between UE5 and Python.

This is a complex setup that involves multiple pieces working in tandem, but starting with simple Python-to-UE5 communication, followed by incrementally adding reinforcement learning logic, is likely the most practical way forward.

(The above is an AI I trained on Unreal Engine API’s - use and refer to at your discretion)
