Use the PyTorch Model Predict function block in the matlab2024a simulink module to import a neural network trained using pytorch.
10 views (last 30 days)
Show older comments
大家好,我现在准备用matlab2024a,simulink中的PyTorch Model Predict来导入在pytorch中训练好的神经网络输入到simulink中做机器人动力学控制。我现在的环境配置是:matlab2024a,conda环境的python环境,解释器版本3.9,pytorch版本采用的 cpu版本,神经网络也已经保存为cpu版本。
在matlab命令行检查python:
>>pyenv
ans =
PythonEnvironment - 属性:
Version: "3.9"
Executable: "C:\Users\64375\.conda\envs\conda_env_39\python.exe"
Library: "C:\Users\64375\.conda\envs\conda_env_39\python39.dll"
Home: "C:\Users\64375\.conda\envs\conda_env_39"
Status: Loaded
ExecutionMode: InProcess
ProcessID: "21020"
ProcessName: "MATLAB"
在simulink模块中按照官方的教程导入神经网络policy_net_matlab.pth文件,使用函数torch.load(). 输入维度与输出维度设置与网络参数一致。没有加载前处理与后处理函数。因为用不到。点击运行报如下错误,如图片所示:
0 Comments
Answers (0)
See Also
Categories
Find more on Big Data Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!