2016-09-17 11 views
-2

私はnprtoolを使ってXORゲートでニューラルネットワークを訓練しました。私はそれを私の.netアプリケーションにエクスポートしたい。私はsim関数を使ってネットワークをシミュレートし、期待される結果を得ました。しかし、私は私のドットネットアプリケーションで使用できるように私は重量を書き出す必要があるので、sim関数は、MATLABの外で動作しません。私はこの関数を書いてmatlabでテストしました。問題は、関数がmatlabでsim関数を使用したときと同じ結果を返さないということです。私は助けが必要です!matlab sim関数が別の答えを与える

function [ Result ] = TrainedXOR_net(input) 
load C:\Users\Student\Desktop\my_MatlabFiles\SampleXOR_Net.mat 
y1 = tansig(net.IW{1}* input + net.b{1}); 
Resut = tansig(net.LW{2}* y1 + net.b{2}); 
end 

答えて

1

私はそれを分類しました。同じ問題を抱えている別の人が簡単にソートできるように、私のソリューションを投稿したいだけです。私は入力上でいくつかの前処理を行い、出力上で後処理をする必要があることが判明しました。

function [ Result ] = TrainedXOR_net(inputs) 
%This is just to load the pre-trained network from the location i saved it. 
load C:\Users\Student\Desktop\my_MatlabFiles\SampleXOR_Net.mat 
for iii = 1:numel(net.inputs{1}.processFcns) 

inputs = feval(net.inputs{1}.processFcns{iii}, 'apply', inputs,    net.inputs{1}.processSettings{iii}); 
end 
y1 = tansig(net.IW{1}* inputs + net.b{1}); 
Result = tansig(net.LW{2}* y1 + net.b{2}); 
for iii = 1:numel(net.outputs{2}.processFcns) 
Result = feval(net.outputs{2}.processFcns{iii},'reverse', Result,  net.outputs{2}.processSettings{iii}); 
end 

このコードでは、私は今sim関数と同じ結果になります。これが誰かを助けることを願っています...

関連する問題