Neural Network : static output when using Matlab Engine API

Hi
i'm executing the same code (1 function with 1 output) from a C++ program and directly from Matlab . Part of the code is a neural network.
I train the NN with the same datas, and then input a = [1:1000]; in both cases
When i run from Matlab, the results vary a little bit, which is good because the training and the initialization of the NN changes the result
But when i run the exact same function from the API using C++, the results are always the same, exactly (to the digit) : 1000.389770327335
how weird is that?
Also with the NN, i try to predict the next value of a known signal. And it gives me the last input , not the predicted (but when i do it in Matlab, it predicts okay ). As if the NN wasn't trained or something...
also i'm using Matlab R2013a student version, is it compatible?
thanks
Jeff
edit : here is a simple code that outputs same numbers each time when used through Engine API:
function out = temptest1()
predictionShift = +1;%+1
timeWindowSize = 4;
fileClose = fopen('EURUSD15.csv');
i = 1;
while i <= 1000
line = fgets(fileClose);
ss = strsplit(line, ',');
closev1(i,1) = str2double(ss(6));
i = i+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%main train neural network
nHidden = 3;
mainNet = feedforwardnet(nHidden);
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
targetsD = [];
inputsD = [];
for shift = 1:length(closev1)-(timeWindowSize-1)-predictionShift - 5
window = closev1(shift : shift + (timeWindowSize -1));
window = window';
inputsD(end+1,1:length(window)) = window;
targetsD(end+1, 1) = closev1(shift + (timeWindowSize -1) + predictionShift, 1); % desired output
end
mainNet = configure(mainNet, inputsD', targetsD');
[mainNet,tr] = train(mainNet, inputsD', targetsD');
closev=[1:1000]'
a1 = mainNet(closev');
out = a1(1, end);

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by