Chnage arma::square to square in methods
Signed-off-by: Omar Shrit <omar@avontech.fr>
This commit is contained in:
@@ -45,8 +45,8 @@ DataType NormalDistribution<DataType>::LogProbability(
|
||||
const DataType& observation) const
|
||||
{
|
||||
const DataType v1 = arma::log(sigma) + std::log(std::sqrt(2 * M_PI));
|
||||
const DataType v2 = arma::square(observation - mean) /
|
||||
(2 * arma::square(sigma));
|
||||
const DataType v2 = square(observation - mean) /
|
||||
(2 * square(sigma));
|
||||
return (-v1 - v2);
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ void NormalDistribution<DataType>::ProbBackward(
|
||||
DataType& dmu,
|
||||
DataType& dsigma) const
|
||||
{
|
||||
dmu = (observation - mean) / (arma::square(sigma)) % Probability(observation);
|
||||
dmu = (observation - mean) / (square(sigma)) % Probability(observation);
|
||||
dsigma = (- 1.0 / sigma +
|
||||
(arma::square(observation - mean) / arma::pow(sigma, 3)))
|
||||
(square(observation - mean) / arma::pow(sigma, 3)))
|
||||
% Probability(observation);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ VirtualBatchNormType<InputType, OutputType>::VirtualBatchNormType(
|
||||
loading(false)
|
||||
{
|
||||
referenceBatchMean = arma::mean(referenceBatch, 1);
|
||||
referenceBatchMeanSquared = arma::mean(arma::square(referenceBatch), 1);
|
||||
referenceBatchMeanSquared = arma::mean(square(referenceBatch), 1);
|
||||
newCoefficient = 1.0 / (referenceBatch.n_cols + 1);
|
||||
oldCoefficient = 1 - newCoefficient;
|
||||
}
|
||||
@@ -68,12 +68,12 @@ void VirtualBatchNormType<InputType, OutputType>::Forward(
|
||||
|
||||
inputParameter = input;
|
||||
InputType inputMean = arma::mean(input, 1);
|
||||
InputType inputMeanSquared = arma::mean(arma::square(input), 1);
|
||||
InputType inputMeanSquared = arma::mean(square(input), 1);
|
||||
|
||||
mean = oldCoefficient * referenceBatchMean + newCoefficient * inputMean;
|
||||
OutputType meanSquared = oldCoefficient * referenceBatchMeanSquared +
|
||||
newCoefficient * inputMeanSquared;
|
||||
variance = meanSquared - arma::square(mean);
|
||||
variance = meanSquared - square(mean);
|
||||
// Normalize the input.
|
||||
output = input.each_col() - mean;
|
||||
inputSubMean = output;
|
||||
|
||||
@@ -30,7 +30,7 @@ typename MatType::elem_type MeanSquaredErrorType<MatType>::Forward(
|
||||
const MatType& target)
|
||||
{
|
||||
typename MatType::elem_type lossSum =
|
||||
arma::accu(arma::square(prediction - target));
|
||||
arma::accu(square(prediction - target));
|
||||
|
||||
if (reduction)
|
||||
return lossSum;
|
||||
|
||||
@@ -31,7 +31,7 @@ typename MatType::elem_type MeanSquaredLogarithmicErrorType<MatType>::Forward(
|
||||
const MatType& target)
|
||||
{
|
||||
typename MatType::elem_type lossSum =
|
||||
arma::accu(arma::square(arma::log(1.0 + target) -
|
||||
arma::accu(square(arma::log(1.0 + target) -
|
||||
arma::log(1.0 + prediction)));
|
||||
|
||||
if (reduction)
|
||||
|
||||
@@ -76,7 +76,7 @@ RBM<InitializationRuleType, DataType, PolicyType>::FreeEnergy(
|
||||
|
||||
for (size_t i = 0; i < hiddenSize; ++i)
|
||||
{
|
||||
ElemType sum = arma::accu(arma::square(input.t() * weight.slice(i))) /
|
||||
ElemType sum = arma::accu(square(input.t() * weight.slice(i))) /
|
||||
(2.0 * slabPenalty);
|
||||
freeEnergy -= SoftplusFunction::Fn(spikeBias(i) - sum);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class MSEGain
|
||||
Sum(values, begin, end, mean);
|
||||
mean /= (double) (end - begin);
|
||||
|
||||
mse = arma::accu(arma::square(values.subvec(begin, end - 1) - mean));
|
||||
mse = arma::accu(square(values.subvec(begin, end - 1) - mean));
|
||||
mse /= (double) (end - begin);
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ class MSEGain
|
||||
|
||||
if (UseWeights)
|
||||
{
|
||||
totalSumSquares = arma::accu(weights % arma::square(responses));
|
||||
totalSumSquares = arma::accu(weights % square(responses));
|
||||
for (size_t i = 0; i < minimum - 1; ++i)
|
||||
{
|
||||
const WType w = weights[i];
|
||||
@@ -192,7 +192,7 @@ class MSEGain
|
||||
}
|
||||
else
|
||||
{
|
||||
totalSumSquares = arma::accu(arma::square(responses));
|
||||
totalSumSquares = arma::accu(square(responses));
|
||||
for (size_t i = 0; i < minimum - 1; ++i)
|
||||
{
|
||||
const RType x = responses[i];
|
||||
|
||||
@@ -329,7 +329,7 @@ inline double LocalCoordinateCoding::Objective(
|
||||
const size_t pointInd = (size_t) (adjacencies(l) / atoms);
|
||||
|
||||
weightedL1NormZ += fabs(codes(atomInd, pointInd)) * arma::as_scalar(
|
||||
arma::sum(arma::square(dictionary.col(atomInd) - data.col(pointInd))));
|
||||
arma::sum(square(dictionary.col(atomInd) - data.col(pointInd))));
|
||||
}
|
||||
|
||||
double froNormResidual = norm(data - dictionary * codes, "fro");
|
||||
|
||||
@@ -182,7 +182,7 @@ inline double SparseCoding::OptimizeDictionary(const arma::mat& data,
|
||||
|
||||
arma::mat matAInvZXT = solve(A, codesXT);
|
||||
|
||||
arma::vec gradient = -arma::sum(arma::square(matAInvZXT), 1);
|
||||
arma::vec gradient = -arma::sum(square(matAInvZXT), 1);
|
||||
gradient += 1;
|
||||
|
||||
arma::mat hessian = -(-2 * (matAInvZXT * trans(matAInvZXT)) % inv(A));
|
||||
|
||||
Reference in New Issue
Block a user