Error in example slexPyTorchPredictExample
显示 更早的评论
Error due to multiple causes.
Caused by:
Error using PredictResponsesPyTorchModelPredictBlockExample (line 6)
MATLAB System block 'slexPyTorchPredictExample/PyTorch Model Predict/PyTorch Model Block' error occurred when invoking 'getOutputSizeImpl' method of 'nnet.pycoexblks.PyTorchModelBlock'. The error was thrown from '
'C:\Program Files\Matlab\R2025b\toolbox\nnet\pycoexblks\+nnet\+pycoexblks\PyTorchModelBlock.m' at line 47
'C:\Program Files\Matlab\R2025b\toolbox\shared\pycoexblks\+internal\+pycoexblks\PythonModelBlockBase.p' at line 0
'C:\Program Files\Matlab\R2025b\toolbox\shared\pycoexblks\+internal\+pycoexblks\PythonModelBlockBase.p' at line 0
'C:\Users\<username>\Documents\MATLAB\Examples\R2025b\deeplearning_shared\PredictResponsesPyTorchModelPredictBlockExample\PredictResponsesPyTorchModelPredictBlockExample.mlx' at line 6'.
Error using PredictResponsesPyTorchModelPredictBlockExample (line 6)
Unable to load specified PyTorch model file 'ptmodel.pth' in Python. The PyTorch model file must be valid, and the PyTorch model class must be on the Python path. The Python error message is: 'The Python model could not be loaded. The Python error message was: 'Python Error: ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject'.'.
Error using PredictResponsesPyTorchModelPredictBlockExample (line 6)
Error in port widths or dimensions. 'Output Port 1' of 'slexPyTorchPredictExample/PyTorch Model Predict/In1' is a one dimensional vector with 34 elements.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Call Python from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!