BP_LDA.LDA_Learn.ComputeRegularizedCrossEntropy C# (CSharp) Method

ComputeRegularizedCrossEntropy() public static method

public static ComputeRegularizedCrossEntropy ( SparseMatrix Xt, DenseMatrix Phi, DenseMatrix theta_top, DenseColumnVector b ) : float
Xt LinearAlgebra.SparseMatrix
Phi LinearAlgebra.DenseMatrix
theta_top LinearAlgebra.DenseMatrix
b LinearAlgebra.DenseColumnVector
return float
		public static float ComputeRegularizedCrossEntropy(SparseMatrix Xt, DenseMatrix Phi, DenseMatrix theta_top, DenseColumnVector b)
		{
			SparseMatrix TmpSparseMat = new SparseMatrix(Xt);
			DenseRowVector TmpDenseRowVec = new DenseRowVector(Xt.nCols);
			MatrixOperation.MatrixMultiplyMatrix(TmpSparseMat, Phi, theta_top);
			MatrixOperation.Log(TmpSparseMat);
			MatrixOperation.ElementwiseMatrixMultiplyMatrix(TmpSparseMat, Xt);
			MatrixOperation.VerticalSumMatrix(TmpDenseRowVec, TmpSparseMat);
			float CE = (-1.0f) * TmpDenseRowVec.VectorValue.Sum();
			DenseMatrix TmpDenseMat = new DenseMatrix(theta_top.nRows, theta_top.nCols);
			MatrixOperation.Log(TmpDenseMat, theta_top);
			MatrixOperation.bsxfunVectorMultiplyMatrix(TmpDenseMat, b);
			MatrixOperation.VerticalSumMatrix(TmpDenseRowVec, TmpDenseMat);
			CE = CE - TmpDenseRowVec.VectorValue.Sum();
			return CE;
		}