# ML Deformer couldn't load network

**URL:** <https://forums.unrealengine.com/t/ml-deformer-couldnt-load-network/1786496>\
**Category:** Character & Animation\
**Tags:** unreal-engine, question\
**Created:** [April 3, 2024, 6:01pm UTC](https://forums.unrealengine.com/t/ml-deformer-couldnt-load-network/1786496 "2024-04-03T18:01:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Desmarkie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Desmarkie](https://forums.unrealengine.com/u/Desmarkie)\
**Post date:** [April 3, 2024, 6:01pm UTC](https://forums.unrealengine.com/t/ml-deformer-couldnt-load-network/1786496/1 "2024-04-03T18:01:25Z")

</div>

Hello,

I’ve found two similar posts on your forums but no replies that seemed to solve the issue.

> [@ML Deformer, Nearest Neighbor Model](https://forums.unrealengine.com/t/ml-deformer-nearest-neighbor-model/721970/3):
>
> [Capture] its not working for me, help me i tried Neural morph model and its not working

and

> [@ML Deformer Does Not Load My Resulting Trained Model.](https://forums.unrealengine.com/t/ml-deformer-does-not-load-my-resulting-trained-model/1211516):
>
> [Capture] I trained my model with ML Neural Morph Model and after that, it didnt import the data and the error showed up.

I’ve been working through the ML Cloth Generation tutorials but in 5.4 preview and keep tripping up at the final hurdle. Training seems to complete without error but then I get the dialog message  
“Training completed but resulting network couldn’t be loaded!”

Output log as below

```auto
LogPython: Calculating inputs and outputs took 127 seconds.
LogPython: write to ../../../../../../Work/MDD/cloth_5_4_1/Intermediate/NearestNeighborModel//inputs.npy
LogPython: Model successfully trained.
LogPython: export to ../../../../../../Work/MDD/cloth_5_4_1/Intermediate/NearestNeighborModel//NearestNeighborModel.pt
LogScript: Error: Script Msg: Traceback (most recent call last):
  File "C:/Program Files/Epic Games/UE_5.4/Engine/Plugins/Animation/MLDeformer/NearestNeighborModel/Content/Python/init_unreal.py", line 21, in train
    return nearestneighbormodel.train(self)
  File "C:\Program Files/Epic Games/UE_5.4/Engine/Plugins/Animation/MLDeformer/NearestNeighborModel/Content/Python\nearestneighbormodel.py", line 1283, in train
    inputs._mmap.close()
AttributeError: 'numpy.ndarray' object has no attribute '_mmap'
LogScript: Error: Script call stack:
    /Engine/PythonTypes.NearestNeighborPythonTrainingModel.Train
LogMLDeformer: Display: Training duration: 00:16:15 (HH:MM:SS)
LogNearestNeighborModel: Error: Network file 'C:/Work/MDD/cloth_5_4_1/Intermediate/NearestNeighborModel/NearestNeighborModel.ubnne' does not exist!

```

I checked the Intermediate folder for output ( cloth\_5\_4\_1\Intermediate\NearestNeighborModel ) and can see a deltas.bin file which is roughly 2 gig, inputs.npy 1 meg and NearestNeighborModel.pt at 55 megs.

No sign of the .ubnne.

I peppered the train function with some logs for some further tests and everything appears to complete correctly apart from the last step. Any help gladly received.

Cheers!

---

<div class="post-metadata">

**Author:** ![Desmarkie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Desmarkie](https://forums.unrealengine.com/u/Desmarkie)\
**Post date:** [April 4, 2024, 5:48pm UTC](https://forums.unrealengine.com/t/ml-deformer-couldnt-load-network/1786496/2 "2024-04-04T17:48:06Z")

</div>

A little more digging today seems to confirm it’s just the missing \_mmap property causing issues as the python script wasn’t handling the error and so the `save_ubnne_network` method was never called.

By wrapping the error the training appears to complete correctly and the .ubnne file is created.

Python edit on `nearestneighbormodel.py` located in UE\_5.4\Engine\Plugins\Animation\MLDeformer\NearestNeighborModel\Content\Python  
This is within the `train` method at ln1296

```auto
finally:
        if 'train_data' in locals():
            inputs, outputs = train_data
            if isinstance(outputs, np.memmap):
                # inputs._mmap doesn't seem to exist, so wrapping in a try/except so that the network is saved when an error fires
                try:
                    inputs._mmap.close()
                except Exception as e:
                    ue.log_error("MARK:: ERROR")
                    ue.log_error(e)
            del inputs, outputs

            torch.cuda.empty_cache()

```

Leaving this as unresolved for the moment.
