【发布时间】:2015-01-10 04:06:22
【问题描述】:
我正在尝试通过我学校的多核计算服务器上的 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;
来自这篇帖子how to save matlab neural networks toolbox generated figures
我猜我会将它添加到文件的末尾,但我很确定这是不对的。如果有人可以帮助我,将不胜感激!
【问题讨论】:
标签: matlab neural-network