⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trainlm.c

📁 nnToolKit 神经网络工具包是基于 MATLAB 神经网络工具箱自行开发的一组神经网络算法函数库
💻 C
📖 第 1 页 / 共 5 页
字号:

_mexLocalFunctionTable _local_function_table_trainlm
  = { 0, (mexFunctionTableEntry *)NULL };

/*
 * The function "mlfTrainlm" contains the normal interface for the "trainlm"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnet\trainlm.m" (lines
 * 1-348). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfTrainlm(mxArray * * tr,
                     mxArray * * Ac,
                     mxArray * * El,
                     mxArray * * v5,
                     mxArray * * v6,
                     mxArray * * v7,
                     mxArray * * v8,
                     mxArray * net_in,
                     mxArray * Pd,
                     mxArray * Tl,
                     mxArray * Ai,
                     mxArray * Q,
                     mxArray * TS,
                     mxArray * VV,
                     mxArray * TV,
                     mxArray * v9,
                     mxArray * v10,
                     mxArray * v11,
                     mxArray * v12) {
    int nargout = 1;
    mxArray * net = NULL;
    mxArray * tr__ = NULL;
    mxArray * Ac__ = NULL;
    mxArray * El__ = NULL;
    mxArray * v5__ = NULL;
    mxArray * v6__ = NULL;
    mxArray * v7__ = NULL;
    mxArray * v8__ = NULL;
    mlfEnterNewContext(
      7,
      12,
      tr,
      Ac,
      El,
      v5,
      v6,
      v7,
      v8,
      net_in,
      Pd,
      Tl,
      Ai,
      Q,
      TS,
      VV,
      TV,
      v9,
      v10,
      v11,
      v12);
    if (tr != NULL) {
        ++nargout;
    }
    if (Ac != NULL) {
        ++nargout;
    }
    if (El != NULL) {
        ++nargout;
    }
    if (v5 != NULL) {
        ++nargout;
    }
    if (v6 != NULL) {
        ++nargout;
    }
    if (v7 != NULL) {
        ++nargout;
    }
    if (v8 != NULL) {
        ++nargout;
    }
    net
      = Mtrainlm(
          &tr__,
          &Ac__,
          &El__,
          &v5__,
          &v6__,
          &v7__,
          &v8__,
          nargout,
          net_in,
          Pd,
          Tl,
          Ai,
          Q,
          TS,
          VV,
          TV,
          v9,
          v10,
          v11,
          v12);
    mlfRestorePreviousContext(
      7,
      12,
      tr,
      Ac,
      El,
      v5,
      v6,
      v7,
      v8,
      net_in,
      Pd,
      Tl,
      Ai,
      Q,
      TS,
      VV,
      TV,
      v9,
      v10,
      v11,
      v12);
    if (tr != NULL) {
        mclCopyOutputArg(tr, tr__);
    } else {
        mxDestroyArray(tr__);
    }
    if (Ac != NULL) {
        mclCopyOutputArg(Ac, Ac__);
    } else {
        mxDestroyArray(Ac__);
    }
    if (El != NULL) {
        mclCopyOutputArg(El, El__);
    } else {
        mxDestroyArray(El__);
    }
    if (v5 != NULL) {
        mclCopyOutputArg(v5, v5__);
    } else {
        mxDestroyArray(v5__);
    }
    if (v6 != NULL) {
        mclCopyOutputArg(v6, v6__);
    } else {
        mxDestroyArray(v6__);
    }
    if (v7 != NULL) {
        mclCopyOutputArg(v7, v7__);
    } else {
        mxDestroyArray(v7__);
    }
    if (v8 != NULL) {
        mclCopyOutputArg(v8, v8__);
    } else {
        mxDestroyArray(v8__);
    }
    return mlfReturnValue(net);
}

/*
 * The function "mlxTrainlm" contains the feval interface for the "trainlm"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnet\trainlm.m" (lines
 * 1-348). The feval function calls the implementation version of trainlm
 * through this function. This function processes any input arguments and
 * passes them to the implementation version of the function, appearing above.
 */
void mlxTrainlm(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[12];
    mxArray * mplhs[8];
    int i;
    if (nlhs > 8) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: trainlm Line: 1 Column: "
            "1 The function \"trainlm\" was called with mor"
            "e than the declared number of outputs (8)."),
          NULL);
    }
    if (nrhs > 12) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: trainlm Line: 1 Column: "
            "1 The function \"trainlm\" was called with mor"
            "e than the declared number of inputs (12)."),
          NULL);
    }
    for (i = 0; i < 8; ++i) {
        mplhs[i] = NULL;
    }
    for (i = 0; i < 12 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 12; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(
      0,
      12,
      mprhs[0],
      mprhs[1],
      mprhs[2],
      mprhs[3],
      mprhs[4],
      mprhs[5],
      mprhs[6],
      mprhs[7],
      mprhs[8],
      mprhs[9],
      mprhs[10],
      mprhs[11]);
    mplhs[0]
      = Mtrainlm(
          &mplhs[1],
          &mplhs[2],
          &mplhs[3],
          &mplhs[4],
          &mplhs[5],
          &mplhs[6],
          &mplhs[7],
          nlhs,
          mprhs[0],
          mprhs[1],
          mprhs[2],
          mprhs[3],
          mprhs[4],
          mprhs[5],
          mprhs[6],
          mprhs[7],
          mprhs[8],
          mprhs[9],
          mprhs[10],
          mprhs[11]);
    mlfRestorePreviousContext(
      0,
      12,
      mprhs[0],
      mprhs[1],
      mprhs[2],
      mprhs[3],
      mprhs[4],
      mprhs[5],
      mprhs[6],
      mprhs[7],
      mprhs[8],
      mprhs[9],
      mprhs[10],
      mprhs[11]);
    plhs[0] = mplhs[0];
    for (i = 1; i < 8 && i < nlhs; ++i) {
        plhs[i] = mplhs[i];
    }
    for (; i < 8; ++i) {
        mxDestroyArray(mplhs[i]);
    }
}

/*
 * The function "Mtrainlm" is the implementation version of the "trainlm"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnet\trainlm.m" (lines
 * 1-348). 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 [net,tr,Ac,El,v5,v6,v7,v8] = ...
 */
static mxArray * Mtrainlm(mxArray * * tr,
                          mxArray * * Ac,
                          mxArray * * El,
                          mxArray * * v5,
                          mxArray * * v6,
                          mxArray * * v7,
                          mxArray * * v8,
                          int nargout_,
                          mxArray * net_in,
                          mxArray * Pd,
                          mxArray * Tl,
                          mxArray * Ai,
                          mxArray * Q,
                          mxArray * TS,
                          mxArray * VV,
                          mxArray * TV,
                          mxArray * v9,
                          mxArray * v10,
                          mxArray * v11,
                          mxArray * v12) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_trainlm);
    int nargin_
      = mclNargin(
          12, net_in, Pd, Tl, Ai, Q, TS, VV, TV, v9, v10, v11, v12, NULL);
    mxArray * net = NULL;
    mxArray * Zl2 = NULL;
    mxArray * Zi2 = NULL;
    mxArray * Zb2 = NULL;
    mxArray * N2 = NULL;
    mxArray * Ac2 = NULL;
    mxArray * El2 = NULL;
    mxArray * perf2 = NULL;
    mxArray * net2 = NULL;
    mxArray * X2 = NULL;
    mxArray * dX = NULL;
    mxArray * currentTime = NULL;
    mxArray * epochPlus1 = NULL;
    mxArray * normgX = NULL;
    mxArray * jj = NULL;
    mxArray * je = NULL;
    mxArray * epoch = NULL;
    mxArray * vperf = NULL;
    mxArray * Zl = NULL;
    mxArray * Zi = NULL;
    mxArray * Zb = NULL;
    mxArray * N = NULL;
    mxArray * perf = NULL;
    mxArray * ii = NULL;
    mxArray * numParameters = NULL;
    mxArray * X = NULL;
    mxArray * startTime = NULL;
    mxArray * stop = NULL;
    mxArray * flag_stop = NULL;
    mxArray * doTest = NULL;
    mxArray * doValidation = NULL;
    mxArray * this = NULL;
    mxArray * time = NULL;
    mxArray * show = NULL;
    mxArray * mu_max = NULL;
    mxArray * mu_dec = NULL;
    mxArray * mu_inc = NULL;
    mxArray * mu = NULL;
    mxArray * min_grad = NULL;
    mxArray * mem_reduc = NULL;
    mxArray * max_fail = NULL;
    mxArray * goal = NULL;
    mxArray * epochs = NULL;
    mxArray * trainParam = NULL;
    mxArray * ans = NULL;
    mclCopyInputArg(&net, net_in);
    mclCopyArray(&Pd);
    mclCopyArray(&Tl);
    mclCopyArray(&Ai);
    mclCopyArray(&Q);
    mclCopyArray(&TS);
    mclCopyArray(&VV);
    mclCopyArray(&TV);
    mclCopyArray(&v9);
    mclCopyArray(&v10);
    mclCopyArray(&v11);
    mclCopyArray(&v12);
    /*
     * trainlm(net,Pd,Tl,Ai,Q,TS,VV,TV,v9,v10,v11,v12)
     * %TRAINLM Levenberg-Marquardt backpropagation.
     * %
     * %  Syntax
     * %  
     * %    [net,tr] = trainlm(net,Pd,Tl,Ai,Q,TS,VV,TV)
     * %    info = trainlm(code)
     * %
     * %  Description
     * %
     * %    TRAINLM is a network training function that updates weight and
     * %    bias values according to Levenberg-Marquardt optimization.
     * %
     * %    TRAINLM(NET,Pd,Tl,Ai,Q,TS,VV,TV) takes these inputs,
     * %      NET - Neural network.
     * %      Pd  - Delayed input vectors.
     * %      Tl  - Layer target vectors.
     * %      Ai  - Initial input delay conditions.
     * %      Q   - Batch size.
     * %      TS  - Time steps.
     * %      VV  - Either empty matrix [] or structure of validation vectors.
     * %      TV  - Either empty matrix [] or structure of validation vectors.
     * %    and returns,
     * %      NET - Trained network.
     * %      TR  - Training record of various values over each epoch:
     * %            TR.epoch - Epoch number.
     * %            TR.perf  - Training performance.
     * %            TR.vperf - Validation performance.
     * %            TR.tperf - Test performance.
     * %            TR.mu    - Adaptive mu value.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -