Beispiel #1
0
        /// <summary>
        /// MLPの学習と更新
        /// </summary>
        /// <param name="inputs">入力ベクトルの浮動小数点の行列で,1行で1ベクトル.</param>
		/// <param name="outputs">対応する出力ベクトルの浮動小数点の行列で,1行で1ベクトル.</param>
        /// <param name="sample_weights">(RPROPのみ)各サンプルの重みを指定する浮動小数点のベクトル.オプション. 学習において,幾つかのサンプルは他のものより重要な場合がある. 例えば検出率と誤検出率間の適切なバランスを探すために,あるクラスの重みを増加させたい場合など.</param>
        /// <param name="sample_idx">用いるサンプルを表す整数のベクトル(すなわち_inputsと_outputsの行).</param>
        /// <param name="params">学習パラメータ</param>
		/// <param name="flags">学習アルゴリズムを制御する様々なパラメータ</param>
		/// <returns>ネットワークの重みを計算/調整した繰り返し回数.</returns>
#else
		/// <summary>
        /// Trains/updates MLP
        /// </summary>
        /// <param name="inputs">A floating-point matrix of input vectors, one vector per row. </param>
		/// <param name="outputs">A floating-point matrix of the corresponding output vectors, one vector per row. </param>
        /// <param name="sampleWeights">(RPROP only) The optional floating-point vector of weights for each sample. Some samples may be more important than others for training, e.g. user may want to gain the weight of certain classes to find the right balance between hit-rate and false-alarm rate etc. </param>
        /// <param name="sampleIdx">The optional integer vector indicating the samples (i.e. rows of _inputs and _outputs) that are taken into account. </param>
		/// <param name="params">The training params.</param>
        /// <param name="flags">The various parameters to control the training algorithm.</param>
		/// <returns>the number of done iterations.</returns>
#endif
		public virtual int Train(CvMat inputs, CvMat outputs, CvMat sampleWeights, 
			CvMat sampleIdx, CvANN_MLP_TrainParams @params, MLPTrainingFlag flags )
		{    
			if (inputs == null)
                throw new ArgumentNullException("inputs");
            if (outputs == null)
                throw new ArgumentNullException("outputs");

            IntPtr sampleWeightsPtr = (sampleWeights == null) ? IntPtr.Zero : sampleWeights.CvPtr;
			IntPtr sampleIdxPtr = (sampleIdx == null) ? IntPtr.Zero : sampleIdx.CvPtr;

			if(@params == null)
				@params = new CvANN_MLP_TrainParams();

			return MLInvoke.CvANN_MLP_train(
                ptr,
				inputs.CvPtr, 
				outputs.CvPtr, 
				sampleWeightsPtr, 
				sampleIdxPtr,
				@params.NativeStruct,
				(int)flags
			);
		}
Beispiel #2
0
        /// <summary>
        /// MLPの学習と更新
        /// </summary>
        /// <param name="inputs">入力ベクトルの浮動小数点の行列で,1行で1ベクトル.</param>
		/// <param name="outputs">対応する出力ベクトルの浮動小数点の行列で,1行で1ベクトル.</param>
        /// <param name="sample_weights">(RPROPのみ)各サンプルの重みを指定する浮動小数点のベクトル.オプション. 学習において,幾つかのサンプルは他のものより重要な場合がある. 例えば検出率と誤検出率間の適切なバランスを探すために,あるクラスの重みを増加させたい場合など.</param>
        /// <param name="sample_idx">用いるサンプルを表す整数のベクトル(すなわち_inputsと_outputsの行).</param>
        /// <param name="params">学習パラメータ</param>
		/// <returns>ネットワークの重みを計算/調整した繰り返し回数.</returns>
#else
		/// <summary>
        /// Trains/updates MLP
        /// </summary>
        /// <param name="inputs">A floating-point matrix of input vectors, one vector per row. </param>
		/// <param name="outputs">A floating-point matrix of the corresponding output vectors, one vector per row. </param>
        /// <param name="sampleWeights">(RPROP only) The optional floating-point vector of weights for each sample. Some samples may be more important than others for training, e.g. user may want to gain the weight of certain classes to find the right balance between hit-rate and false-alarm rate etc. </param>
        /// <param name="sampleIdx">The optional integer vector indicating the samples (i.e. rows of _inputs and _outputs) that are taken into account. </param>
		/// <param name="params">The training params.</param>
		/// <returns>the number of done iterations.</returns>
#endif
		public virtual Int32 Train(CvMat inputs, CvMat outputs, CvMat sampleWeights, 
			CvMat sampleIdx, CvANN_MLP_TrainParams @params)
		{    
			return Train(inputs, outputs, sampleWeights, sampleIdx, @params, MLPTrainingFlag.Zero);
		}