Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab神经网络工具箱将回归图保存到文件_Matlab_Neural Network - Fatal编程技术网

Matlab神经网络工具箱将回归图保存到文件

Matlab神经网络工具箱将回归图保存到文件,matlab,neural-network,Matlab,Neural Network,我正试图通过我在学校的多核计算服务器上的ssh连接,用一个相当大的数据集运行一个matlab脚本(由nftool生成,因为我的matlab知识最差)。因为我不能直接查看网络培训时生成的图形界面,所以我想将绘图保存到一个文件中(我认为我最想要的是回归图),以便在作业运行后查看它。我只编辑了自动导入数据文件的代码 % Solve an Input-Output Fitting problem with a Neural Network % Script generated by NFTOOL % C

我正试图通过我在学校的多核计算服务器上的ssh连接,用一个相当大的数据集运行一个matlab脚本(由nftool生成,因为我的matlab知识最差)。因为我不能直接查看网络培训时生成的图形界面,所以我想将绘图保存到一个文件中(我认为我最想要的是回归图),以便在作业运行后查看它。我只编辑了自动导入数据文件的代码

% Solve an Input-Output Fitting problem with a Neural Network
% Script generated by NFTOOL
% Created Tue Nov 11 21:20:40 CST 2014
%
% This script assumes these variables are defined:
%
%   NNinput - input data.
%   NNoutput - target data.

% sets the same seed every time, so the rand() sequence is always identical
RandStream.setGlobalStream(RandStream('mt19937ar','seed',1));

close all % closes all of the figures that you have generated in your program
clear all % deletes all stored variables in your workspace
clc       % removes all lines in your command window

NNinput = load('NNinput');
NNoutput = load('NNoutput');

inputs = NNinput;
targets = NNoutput;

inputs = inputs.';
targets = targets.';

% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize);

% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};

% Setup Division of Data for Training, Validation, Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = 'dividerand';  % Divide data randomly
net.divideMode = 'sample';  % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;

% For help on training function 'trainlm' type: help trainlm
% For a list of all training functions type: help nntrain
net.trainFcn = 'trainlm';  % Levenberg-Marquardt

% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = 'mse';  % Mean squared error

% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
  'plotregression', 'plotfit'};


% Train the Network
[net,tr] = train(net,inputs,targets);

% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)

% Recalculate Training, Validation and Test Performance
trainTargets = targets .* tr.trainMask{1};
valTargets = targets  .* tr.valMask{1};
testTargets = targets  .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)
到目前为止,我能想到的只是

h = findobj('Type', plotregression(targets, outputs), TRAINING_PLOTREGRESSION, 'regressionPlot');
for k = 1:numel(h)
    print(h(k), sprintf('Pic%d.ps',k));
end;
从这篇文章


我猜我会把这个添加到文件的末尾,但我很确定这是不对的。如果有人能帮我,我将不胜感激

这可能是保存有关训练的情节的最基本方法。您已经在代码的这一部分中选择了绘图函数:

% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
  'plotregression', 'plotfit'};
因此,现在您只需在代码末尾(或训练网络后的任何地方)调用每个绘图函数,并使用
print
保存绘图:

plotperform(tr);
print('-dpsc', 'perform')
plottrainstate(tr);
print('-dpsc', 'trainstate')
ploterrhist(tr);
print('-dpsc', 'errhist')
plotregression(tr);
print('-dpsc', 'regression')
plotfit(tr);
print('-dpsc', 'fit')

print
的第一个参数选择打印机驱动程序,在本例中为PostScript Level 3颜色,第二个参数是图形的名称。有关
print
的更多信息,请参阅!工作得很有魅力