📄 plotperf.c
字号:
* M-function from file "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines
* 1-207). The void interface is only produced if the M-function uses the
* special variable "nargout", and has at least one output. The void interface
* function specifies zero output arguments to the implementation version of
* the function, and in the event that the implementation version still returns
* an output (which, in MATLAB, would be assigned to the "ans" variable), it
* deallocates the output. This function processes any input arguments and
* passes them to the implementation version of the function, appearing above.
*/
void mlfVPlotperf(mxArray * tr,
mxArray * goal,
mxArray * name,
mxArray * epoch) {
mxArray * stop = NULL;
mlfEnterNewContext(0, 4, tr, goal, name, epoch);
stop = Mplotperf(0, tr, goal, name, epoch);
mlfRestorePreviousContext(0, 4, tr, goal, name, epoch);
mxDestroyArray(stop);
}
/*
* The function "mlxPlotperf" contains the feval interface for the "plotperf"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines
* 1-207). The feval function calls the implementation version of plotperf
* through this function. This function processes any input arguments and
* passes them to the implementation version of the function, appearing above.
*/
void mlxPlotperf(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
mxArray * mprhs[4];
mxArray * mplhs[1];
int i;
if (nlhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: plotperf Line: 1 Column:"
" 1 The function \"plotperf\" was called with m"
"ore than the declared number of outputs (1)."),
NULL);
}
if (nrhs > 4) {
mlfError(
mxCreateString(
"Run-time Error: File: plotperf Line: 1 Column:"
" 1 The function \"plotperf\" was called with m"
"ore than the declared number of inputs (4)."),
NULL);
}
for (i = 0; i < 1; ++i) {
mplhs[i] = NULL;
}
for (i = 0; i < 4 && i < nrhs; ++i) {
mprhs[i] = prhs[i];
}
for (; i < 4; ++i) {
mprhs[i] = NULL;
}
mlfEnterNewContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
mplhs[0] = Mplotperf(nlhs, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
mlfRestorePreviousContext(0, 4, mprhs[0], mprhs[1], mprhs[2], mprhs[3]);
plhs[0] = mplhs[0];
}
/*
* The function "mlfPlotperf_find_existing_figure" contains the normal
* interface for the "plotperf/find_existing_figure" M-function from file
* "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines 207-232). This function
* processes any input arguments and passes them to the implementation version
* of the function, appearing above.
*/
static mxArray * mlfPlotperf_find_existing_figure(void) {
int nargout = 1;
mxArray * fig = NULL;
mlfEnterNewContext(0, 0);
fig = Mplotperf_find_existing_figure(nargout);
mlfRestorePreviousContext(0, 0);
return mlfReturnValue(fig);
}
/*
* The function "mlxPlotperf_find_existing_figure" contains the feval interface
* for the "plotperf/find_existing_figure" M-function from file
* "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines 207-232). The feval
* function calls the implementation version of plotperf/find_existing_figure
* through this function. This function processes any input arguments and
* passes them to the implementation version of the function, appearing above.
*/
static void mlxPlotperf_find_existing_figure(int nlhs,
mxArray * plhs[],
int nrhs,
mxArray * prhs[]) {
mxArray * mplhs[1];
int i;
if (nlhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: plotperf/find_existing_figure Line: 207"
" Column: 1 The function \"plotperf/find_existing_figure\" was"
" called with more than the declared number of outputs (1)."),
NULL);
}
if (nrhs > 0) {
mlfError(
mxCreateString(
"Run-time Error: File: plotperf/find_existing_figure Line: 207"
" Column: 1 The function \"plotperf/find_existing_figure\" was"
" called with more than the declared number of inputs (0)."),
NULL);
}
for (i = 0; i < 1; ++i) {
mplhs[i] = NULL;
}
mlfEnterNewContext(0, 0);
mplhs[0] = Mplotperf_find_existing_figure(nlhs);
mlfRestorePreviousContext(0, 0);
plhs[0] = mplhs[0];
}
/*
* The function "mlfPlotperf_new_figure" contains the normal interface for the
* "plotperf/new_figure" M-function from file
* "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines 232-244). This function
* processes any input arguments and passes them to the implementation version
* of the function, appearing above.
*/
static mxArray * mlfPlotperf_new_figure(mxArray * name) {
int nargout = 1;
mxArray * fig = NULL;
mlfEnterNewContext(0, 1, name);
fig = Mplotperf_new_figure(nargout, name);
mlfRestorePreviousContext(0, 1, name);
return mlfReturnValue(fig);
}
/*
* The function "mlxPlotperf_new_figure" contains the feval interface for the
* "plotperf/new_figure" M-function from file
* "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines 232-244). The feval
* function calls the implementation version of plotperf/new_figure through
* this function. This function processes any input arguments and passes them
* to the implementation version of the function, appearing above.
*/
static void mlxPlotperf_new_figure(int nlhs,
mxArray * plhs[],
int nrhs,
mxArray * prhs[]) {
mxArray * mprhs[1];
mxArray * mplhs[1];
int i;
if (nlhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: plotperf/new_figure Line: 232 Co"
"lumn: 1 The function \"plotperf/new_figure\" was calle"
"d with more than the declared number of outputs (1)."),
NULL);
}
if (nrhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: plotperf/new_figure Line: 232 Co"
"lumn: 1 The function \"plotperf/new_figure\" was calle"
"d with more than the declared number of inputs (1)."),
NULL);
}
for (i = 0; i < 1; ++i) {
mplhs[i] = NULL;
}
for (i = 0; i < 1 && i < nrhs; ++i) {
mprhs[i] = prhs[i];
}
for (; i < 1; ++i) {
mprhs[i] = NULL;
}
mlfEnterNewContext(0, 1, mprhs[0]);
mplhs[0] = Mplotperf_new_figure(nlhs, mprhs[0]);
mlfRestorePreviousContext(0, 1, mprhs[0]);
plhs[0] = mplhs[0];
}
/*
* The function "mlfPlotperf_createNewPlot" contains the normal interface for
* the "plotperf/createNewPlot" M-function from file
* "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines 244-276). This function
* processes any input arguments and passes them to the implementation version
* of the function, appearing above.
*/
static void mlfPlotperf_createNewPlot(mxArray * fig) {
mlfEnterNewContext(0, 1, fig);
Mplotperf_createNewPlot(fig);
mlfRestorePreviousContext(0, 1, fig);
}
/*
* The function "mlxPlotperf_createNewPlot" contains the feval interface for
* the "plotperf/createNewPlot" M-function from file
* "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines 244-276). The feval
* function calls the implementation version of plotperf/createNewPlot through
* this function. This function processes any input arguments and passes them
* to the implementation version of the function, appearing above.
*/
static void mlxPlotperf_createNewPlot(int nlhs,
mxArray * plhs[],
int nrhs,
mxArray * prhs[]) {
mxArray * mprhs[1];
int i;
if (nlhs > 0) {
mlfError(
mxCreateString(
"Run-time Error: File: plotperf/createNewPlot Line: 244 C"
"olumn: 1 The function \"plotperf/createNewPlot\" was cal"
"led with more than the declared number of outputs (0)."),
NULL);
}
if (nrhs > 1) {
mlfError(
mxCreateString(
"Run-time Error: File: plotperf/createNewPlot Line: 244 C"
"olumn: 1 The function \"plotperf/createNewPlot\" was cal"
"led with more than the declared number of inputs (1)."),
NULL);
}
for (i = 0; i < 1 && i < nrhs; ++i) {
mprhs[i] = prhs[i];
}
for (; i < 1; ++i) {
mprhs[i] = NULL;
}
mlfEnterNewContext(0, 1, mprhs[0]);
Mplotperf_createNewPlot(mprhs[0]);
mlfRestorePreviousContext(0, 1, mprhs[0]);
}
/*
* The function "Mplotperf" is the implementation version of the "plotperf"
* M-function from file "d:\matlab6p5\toolbox\nnet\nnet\plotperf.m" (lines
* 1-207). It contains the actual compiled code for that M-function. It is a
* static function and must only be called from one of the interface functions,
* appearing below.
*/
/*
* function stop=plotperf(tr,goal,name,epoch)
*/
static mxArray * Mplotperf(int nargout_,
mxArray * tr,
mxArray * goal,
mxArray * name,
mxArray * epoch) {
mexLocalFunctionTable save_local_function_table_
= mclSetCurrentLocalFunctionTable(&_local_function_table_plotperf);
int nargin_ = mclNargin(4, tr, goal, name, epoch, NULL);
mxArray * stop = NULL;
mxArray * ystring = NULL;
mxArray * tstring = NULL;
mxArray * yscale = NULL;
mxArray * plotGoal = NULL;
mxArray * plotTest = NULL;
mxArray * plotValidation = NULL;
mxArray * ymin = NULL;
mxArray * ymax = NULL;
mxArray * ind = NULL;
mxArray * fig2 = NULL;
mxArray * ud = NULL;
mxArray * fig = NULL;
mxArray * ans = NULL;
mclCopyArray(&tr);
mclCopyArray(&goal);
mclCopyArray(&name);
mclCopyArray(&epoch);
/*
* %PLOTPERF Plot network performance.
* %
* % Syntax
* %
* % plotperf(tr,goal,name,epoch)
* %
* % Description
* %
* % PLOTPERF(TR,GOAL,NAME,EPOCH) takes these inputs,
* % TR - Training record returned by train.
* % GOAL - Performance goal, default = NaN.
* % NAME - Training function name, default = ''.
* % EPOCH - Number of epochs, default = length of training record.
* % and plots the training performance, and if available, the performance
* % goal, validation performance, and test performance.
* %
* % Example
* %
* % Here are 8 input values P and associated targets T, plus a like
* % number of validation inputs VV.P and targets VV.T.
* %
* % P = 1:8; T = sin(P);
* % VV.P = P; VV.T = T+rand(1,8)*0.1;
* %
* % The code below creates a network and trains it on this problem.
* %
* % net = newff(minmax(P),[4 1],{'tansig','tansig'});
* % [net,tr] = train(net,P,T,[],[],VV);
* %
* % During training PLOTPERF was called to display the training
* % record. You can also call PLOTPERF directly with the final
* % training record TR, as shown below.
* %
* % plotperf(tr)
*
* % Mark Beale 11-31-97, Orlando De Jesus 11-11-98, MHB 12-29-99
* % Copyright 1992-2002 The MathWorks, Inc.
* % $Revision: 1.12 $ $Date: 2002/03/25 16:53:14 $
*
* % ERROR CHECKS, DEFAULTS AND 3 SPECIAL CASES
* % ==========================================
*
* % Error check: must be at least one argument
* if nargin < 1, error('Not enough input arguments.'); end
*/
if (nargin_ < 1) {
mlfError(_mxarray0_, NULL);
}
/*
*
* % Special case 1: 'stop' callback
* if (nargin == 1) & isstr(tr)
*/
{
mxArray * a_ = mclInitialize(mclBoolToArray(nargin_ == 1));
if (mlfTobool(a_) && mlfTobool(mclAnd(a_, mlfIsstr(mclVa(tr, "tr"))))) {
mxDestroyArray(a_);
/*
* if strcmp(tr,'stop')
*/
if (mlfTobool(mlfStrcmp(mclVa(tr, "tr"), _mxarray2_))) {
/*
* fig = find_existing_figure;
*/
mlfAssign(&fig, mlfPlotperf_find_existing_figure());
/*
* if (fig)
*/
if (mlfTobool(mclVv(fig, "fig"))) {
/*
* ud=get(fig,'UserData');
*/
mlfAssign(
&ud, mlfNGet(1, mclVv(fig, "fig"), _mxarray4_, NULL));
/*
* ud.stop=1;
*/
mlfIndexAssign(&ud, ".stop", _mxarray6_);
/*
* set(fig,'UserData',ud);
*/
mclAssignAns(
&ans,
mlfNSet(
0,
mclVv(fig, "fig"),
_mxarray4_,
mclVv(ud, "ud"),
NULL));
/*
* end
*/
}
/*
* end
*/
}
/*
* if (nargout) stop = 1; end
*/
if (nargout_ != 0) {
mlfAssign(&stop, _mxarray6_);
}
/*
* return
*/
goto return_;
} else {
mxDestroyArray(a_);
}
/*
* end
*/
}
/*
*
* % Defaults
* if nargin < 2, goal = NaN; end
*/
if (nargin_ < 2) {
mlfAssign(&goal, _mxarray7_);
}
/*
* if nargin < 3, name = 'Training Record'; end
*/
if (nargin_ < 3) {
mlfAssign(&name, _mxarray8_);
}
/*
* if nargin < 4, epoch = length(tr.epoch)-1; end
*/
if (nargin_ < 4) {
mlfAssign(
&epoch,
mclMinus(
mclFeval(
mclValueVarargout(),
mlxLength,
mlfIndexRef(mclVa(tr, "tr"), ".epoch"),
NULL),
_mxarray6_));
}
/*
*
* % Special case 2: Delete plot if zero epochs
* if (epoch == 0) | isnan(tr.perf(1))
*/
{
mxArray * a_ = mclInitialize(mclEq(mclVa(epoch, "epoch"), _mxarray10_));
if (mlfTobool(a_)
|| mlfTobool(
mclOr(
a_,
mclFeval(
mclValueVarargout(),
mlxIsnan,
mlfIndexRef(mclVa(tr, "tr"), ".perf(?)", _mxarray6_),
NULL)))) {
mxDestroyArray(a_);
/*
* fig = find_existing_figure;
*/
mlfAssign(&fig, mlfPlotperf_find_existing_figure());
/*
* if (fig), delete(fig); end
*/
if (mlfTobool(mclVv(fig, "fig"))) {
mlfDelete(mclVv(fig, "fig"), NULL);
}
/*
* if (nargout) stop = 0; end
*/
if (nargout_ != 0) {
mlfAssign(&stop, _mxarray10_);
}
/*
* return
*/
goto return_;
} else {
mxDestroyArray(a_);
}
/*
* end
*/
}
/*
*
* % Special case 3: No plot if performance is NaN
* if (epoch == 0) | isnan(tr.perf(1))
*/
{
mxArray * a_ = mclInitialize(mclEq(mclVa(epoch, "epoch"), _mxarray10_));
if (mlfTobool(a_)
|| mlfTobool(
mclOr(
a_,
mclFeval(
mclValueVarargout(),
mlxIsnan,
mlfIndexRef(mclVa(tr, "tr"), ".perf(?)", _mxarray6_),
NULL)))) {
mxDestroyArray(a_);
/*
* if (nargout) stop = 0; end
*/
if (nargout_ != 0) {
mlfAssign(&stop, _mxarray10_);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -