Skip to content

Commit

Permalink
update to use .index_max()
Browse files Browse the repository at this point in the history
  • Loading branch information
conradsnicta authored and eddelbuettel committed Nov 22, 2024
1 parent 5b490e4 commit 22d678e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mlpack/methods/perceptron/perceptron_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ void Perceptron<
// Multiply for each variable and check whether the current weight vector
// correctly classifies this.
tempLabelMat = weights.t() * data.col(j) + biases;

tempLabelMat.max(maxIndexRow, maxIndexCol);
maxIndexRow = arma::ind2sub(arma::size(tempLabelMat), tempLabelMat.index_max())(0);

// Check whether prediction is correct.
if (maxIndexRow != labels(0, j))
Expand Down Expand Up @@ -289,7 +289,7 @@ size_t Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Classify(
arma::uword maxIndex = 0;

tempLabelVec = weights.t() * point + biases;
tempLabelVec.max(maxIndex);
maxIndex = tempLabelVec.index_max();

return size_t(maxIndex);
}
Expand Down Expand Up @@ -322,7 +322,7 @@ void Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Classify(
for (size_t i = 0; i < test.n_cols; ++i)
{
tempLabelMat = weights.t() * test.col(i) + biases;
tempLabelMat.max(maxIndex);
maxIndex = tempLabelMat.index_max();
predictedLabels(i) = maxIndex;
}
}
Expand Down

0 comments on commit 22d678e

Please sign in to comment.