Export a neural network trained with MATLAB in other programming languages

前端 未结 5 1624
失恋的感觉
失恋的感觉 2020-12-13 02:44

I trained a neural network using the MATLAB Neural Network Toolbox, and in particular using the command nprtool, which provides a simple GUI to use the toolbox

5条回答
  •  半阙折子戏
    2020-12-13 03:38

    Thanks to VitoShadow and robott answers, I can export Matlab neural network values to other applications.

    I really appreciate them, but I found some trivial errors in their codes and want to correct them.

    1) In the VitoShadow codes,

    Results = tansig(net.LW{2} * y1 + net.b{2});
    -> Results = net.LW{2} * y1 + net.b{2};
    

    2) In the robott preprocessing codes, It would be easier extracting xmax and xmin from the net variable than calculating them.

    xmax = net.inputs{1}.processSettings{1}.xmax
    xmin = net.inputs{1}.processSettings{1}.xmin
    

    3) In the robott postprocessing codes,

    xmax = net.outputs{2}.processSettings{1}.xmax
    xmin = net.outputs{2}.processSettings{1}.xmin
    
    Results = (ymax-ymin)*(Results-xmin)/(xmax-xmin) + ymin;
    -> Results = (Results-ymin)*(xmax-xmin)/(ymax-ymin) + xmin;
    

    You can manually check and confirm the values as follows:

    p2 = mapminmax('apply', net(:, 1), net.inputs{1}.processSettings{1})
    

    -> preprocessed data

    y1 = purelin ( net.LW{2} * tansig(net.iw{1}* p2 + net.b{1}) + net.b{2})
    

    -> Neural Network processed data

    y2 = mapminmax( 'reverse' , y1, net.outputs{2}.processSettings{1})
    

    -> postprocessed data

    Reference: http://www.mathworks.com/matlabcentral/answers/14517-processing-of-i-p-data

提交回复
热议问题