Fix style issues after regexp
Signed-off-by: Omar Shrit <omar@avontech.fr>
This commit is contained in:
@@ -37,8 +37,7 @@ double SequencePrecision(arma::field<MatType> trueOutputs,
|
||||
|
||||
for (size_t i = 0; i < testSize; ++i)
|
||||
{
|
||||
arma::vec delta = vectorise(arma::abs(
|
||||
trueOutputs.at(i) - predOutputs.at(i)));
|
||||
arma::vec delta = vectorise(abs(trueOutputs.at(i) - predOutputs.at(i)));
|
||||
double maxDelta = arma::max(delta);
|
||||
if (maxDelta < tol)
|
||||
{
|
||||
|
||||
@@ -45,8 +45,7 @@ DataType NormalDistribution<DataType>::LogProbability(
|
||||
const DataType& observation) const
|
||||
{
|
||||
const DataType v1 = arma::log(sigma) + std::log(std::sqrt(2 * M_PI));
|
||||
const DataType v2 = square(observation - mean) /
|
||||
(2 * square(sigma));
|
||||
const DataType v2 = square(observation - mean) / (2 * square(sigma));
|
||||
return (-v1 - v2);
|
||||
}
|
||||
|
||||
@@ -57,8 +56,7 @@ void NormalDistribution<DataType>::ProbBackward(
|
||||
DataType& dsigma) const
|
||||
{
|
||||
dmu = (observation - mean) / (square(sigma)) % Probability(observation);
|
||||
dsigma = (- 1.0 / sigma +
|
||||
(square(observation - mean) / arma::pow(sigma, 3)))
|
||||
dsigma = (- 1.0 / sigma + (square(observation - mean) / arma::pow(sigma, 3)))
|
||||
% Probability(observation);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,8 +172,7 @@ void Linear3DType<MatType, RegularizerType>::Gradient(
|
||||
dW.slice(i) = errorTemp.slice(i) * inputTemp.slice(i).t();
|
||||
}
|
||||
|
||||
gradient.submat(0, 0, weight.n_elem - 1, 0)
|
||||
= vectorise(arma::sum(dW, 2));
|
||||
gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise(arma::sum(dW, 2));
|
||||
|
||||
gradient.submat(weight.n_elem, 0, weights.n_elem - 1, 0)
|
||||
= vectorise(arma::sum(arma::sum(errorTemp, 2), 1));
|
||||
|
||||
@@ -128,8 +128,7 @@ void LinearType<MatType, RegularizerType>::Gradient(
|
||||
const MatType& error,
|
||||
MatType& gradient)
|
||||
{
|
||||
gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise(
|
||||
error * input.t());
|
||||
gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise(error * input.t());
|
||||
gradient.submat(weight.n_elem, 0, gradient.n_elem - 1, 0) =
|
||||
arma::sum(error, 1);
|
||||
|
||||
|
||||
@@ -123,8 +123,7 @@ void LinearNoBiasType<MatType, RegularizerType>::Gradient(
|
||||
const MatType& error,
|
||||
MatType& gradient)
|
||||
{
|
||||
gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise(
|
||||
error * input.t());
|
||||
gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise(error * input.t());
|
||||
regularizer.Evaluate(weight, gradient);
|
||||
}
|
||||
|
||||
|
||||
@@ -344,26 +344,22 @@ void LSTMType<MatType>::Gradient(
|
||||
|
||||
// output2GateOutputWeight gradients.
|
||||
gradient.submat(offset, 0, offset + output2GateOutputWeight.n_elem - 1, 0) =
|
||||
vectorise(outputGateError *
|
||||
outParameter.slice(this->CurrentStep()).t());
|
||||
vectorise(outputGateError * outParameter.slice(this->CurrentStep()).t());
|
||||
offset += output2GateOutputWeight.n_elem;
|
||||
|
||||
// output2GateForgetWeight gradients.
|
||||
gradient.submat(offset, 0, offset + output2GateForgetWeight.n_elem - 1, 0) =
|
||||
vectorise(forgetGateError *
|
||||
outParameter.slice(this->CurrentStep()).t());
|
||||
vectorise(forgetGateError * outParameter.slice(this->CurrentStep()).t());
|
||||
offset += output2GateForgetWeight.n_elem;
|
||||
|
||||
// output2GateInputWeight gradients.
|
||||
gradient.submat(offset, 0, offset + output2GateInputWeight.n_elem - 1, 0) =
|
||||
vectorise(inputGateError *
|
||||
outParameter.slice(this->CurrentStep()).t());
|
||||
vectorise(inputGateError * outParameter.slice(this->CurrentStep()).t());
|
||||
offset += output2GateInputWeight.n_elem;
|
||||
|
||||
// output2HiddenWeight gradients.
|
||||
gradient.submat(offset, 0, offset + output2HiddenWeight.n_elem - 1, 0) =
|
||||
vectorise(hiddenError *
|
||||
outParameter.slice(this->CurrentStep()).t());
|
||||
vectorise(hiddenError * outParameter.slice(this->CurrentStep()).t());
|
||||
offset += output2HiddenWeight.n_elem;
|
||||
|
||||
// cell2GateOutputWeight gradients.
|
||||
|
||||
@@ -29,8 +29,7 @@ typename MatType::elem_type MeanSquaredErrorType<MatType>::Forward(
|
||||
const MatType& prediction,
|
||||
const MatType& target)
|
||||
{
|
||||
typename MatType::elem_type lossSum =
|
||||
arma::accu(square(prediction - target));
|
||||
typename MatType::elem_type lossSum = arma::accu(square(prediction - target));
|
||||
|
||||
if (reduction)
|
||||
return lossSum;
|
||||
|
||||
@@ -31,8 +31,7 @@ typename MatType::elem_type MeanSquaredLogarithmicErrorType<MatType>::Forward(
|
||||
const MatType& target)
|
||||
{
|
||||
typename MatType::elem_type lossSum =
|
||||
arma::accu(square(arma::log(1.0 + target) -
|
||||
arma::log(1.0 + prediction)));
|
||||
arma::accu(square(arma::log(1.0 + target) - arma::log(1.0 + prediction)));
|
||||
|
||||
if (reduction)
|
||||
return lossSum;
|
||||
|
||||
@@ -57,8 +57,7 @@ class PearsonSearch
|
||||
// For each vector x, first subtract mean(x) from each element in x.
|
||||
// Then normalize the vector to unit length.
|
||||
arma::mat normalizedSet(arma::size(referenceSet));
|
||||
normalizedSet = normalise(
|
||||
referenceSet.each_row() - arma::mean(referenceSet));
|
||||
normalizedSet = normalise(referenceSet.each_row() - arma::mean(referenceSet));
|
||||
|
||||
neighborSearch.Train(std::move(normalizedSet));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user