Training Models - Interactml/iml-unreal GitHub Wiki

What is Training?

Training is the process by which the algorithm a model uses builds its internal data structures needed to be able to associate all the examples it is given with the output values each is expected to correlate to.

🗑️ Untrained Model + 📚 Examples + 🎚️ Expected Outputs --> 🧠 Trained Model

Training Node

To train a model you use the Teach The Machine blueprint node with both the Model and the Training Set objects plugged into it (or directly selected in the node input drop-down UI).


Hooking up Model and Training Set asset variables

Setting specific Model or Training Set asset

See Asset Types for information on Model and Training Set assets 👉

See Model Types to find out about the models available 👉

User Interaction

Training is normally something done separately to actually running a model since it's effectively part of the configuration of your application rather than the running of it which is the 'normal operation' phase. Of course, you can build applications that feature recording and training as part of their functionality if you want to as well.

The training process is similar in complexity to the recording process, in that a single input needs to be triggered when there are new example data for the model to learn from and the model can be reset by triggering a second input. This is usually going to be done in response to input from the user and will require some more boilerplate script to hook it up. Brief examples of how this is done are provided below but it is beyond the scope of this documentation to describe a more sophisticated and flexible input system, but the provided Demo Project uses such systems and you can learn from and reuse those as you see fit.

Training The Model

The train input can be bound to a controller button or key using standard Blueprint nodes. A simple example might look like this:

Train is a simple Boolean trigger input, activating when the value transitions from false to true ('rising edge' trigger).

Resetting The Model

The attached model can be reset to the untrained state (empty) using the Reset input pin. As for the Training pin it is activated when the value transitions from false to true. As above, you can hook this up to a user input with standard blueprint nodes.

💡 It's not necessary to reset a model before training it. Re-training will always reset the model first anyway.

Results

Any changes made by using the node are applied to the Model asset and will result in a number of things happening:

Outputs

The Teach The Machine node has a Trained output pin that reflects the current model training status. This will be true when a trained model is attached to the node and doesn't need training to have just occurred to provide this information.

You might use this to display a 'trained'/'not trained' indicator in your scene to provide feedback on the current state of the model.

Data

The Model asset will be marked as modified and mean that it shows up as unsaved in the editor. You will need to save the asset to commit the changes to disk. This can either be done using the normal Unreal Editor Save function, or if you are training in a standalone application you can call the InteractML Save function (see Utility Blueprints).

💡 Running in-editor will modify the asset, but it may not show as modified until you end the Play-in-Editor session.

See Your Data for information how how/where the trained model data is stored 👉

Background Training

Training can be run asynchronously as a background task to free up the engine to continue operating and avoid any stalls or stuttering of your application. Depending on the type of model, the amount of training data, and the number of output values, some training tasks can take several seconds to complete.

See Model Types for performance information 👉

To avoid this, a training node can be switched to Background Operation in the details panel for the node.

This changes the nodes outputs slightly, adding two new pins.

  • Training - Is the model currently being trained? (true whilst training ongoing in the background)
  • Completed - Execution output that is fired for one tick after the training has completed

These can be hooked up to provide feedback to the user or trigger a sequence of events that follow training.


👈 Recording Examples | 🏠 Home | Running Models 👉

⚠️ **GitHub.com Fallback** ⚠️