From 94d4384f2077529dbfcd8dab122bd571cccc78d9 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Mon, 15 Aug 2022 13:08:32 -0400 Subject: [PATCH] Remove accidentally reintroduced file. --- .../tests/feedforward_network_2_test.cpp | 138 ------------------ 1 file changed, 138 deletions(-) delete mode 100644 src/mlpack/tests/feedforward_network_2_test.cpp diff --git a/src/mlpack/tests/feedforward_network_2_test.cpp b/src/mlpack/tests/feedforward_network_2_test.cpp deleted file mode 100644 index 8b6500c124..0000000000 --- a/src/mlpack/tests/feedforward_network_2_test.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @file tests/feedforward_network_2_test.cpp - * @author Marcus Edel - * @author Palash Ahuja - * - * Tests the feed forward network. - * - * mlpack is free software; you may redistribute it and/or modify it under the - * terms of the 3-clause BSD license. You should have received a copy of the - * 3-clause BSD license along with mlpack. If not, see - * http://www.opensource.org/licenses/BSD-3-Clause for more information. - */ - -#include - -#include -#include - -#include "catch.hpp" -#include "serialization.hpp" -#include "custom_layer.hpp" - -using namespace mlpack; -using namespace mlpack::ann; -using namespace mlpack::kmeans; - -/** - * Train and evaluate a model with the specified structure. - */ -template -void TestNetwork(ModelType& model, - MatType& trainData, - MatType& trainLabels, - MatType& testData, - MatType& testLabels, - const size_t maxEpochs, - const double classificationErrorThreshold) -{ - ens::RMSProp opt(0.01, 32, 0.88, 1e-8, maxEpochs * trainData.n_cols, -1); - model.Train(trainData, trainLabels, opt); - - MatType predictionTemp; - model.Predict(testData, predictionTemp); - MatType prediction = arma::zeros(1, predictionTemp.n_cols); - - for (size_t i = 0; i < predictionTemp.n_cols; ++i) - { - prediction(i) = arma::as_scalar(arma::find( - arma::max(predictionTemp.col(i)) == predictionTemp.col(i), 1)) + 1; - } - - size_t correct = arma::accu(prediction == testLabels); - double classificationError = 1 - double(correct) / testData.n_cols; - REQUIRE(classificationError <= classificationErrorThreshold); -} - -/** - * Train the RBF network on a larger dataset. - */ -TEST_CASE("RBFNetworkTest", "[FeedForwardNetworkTest]") -{ - // Load the dataset. - arma::mat trainData; - if (!data::Load("thyroid_train.csv", trainData)) - FAIL("Cannot open thyroid_train.csv"); - - arma::mat trainLabels = trainData.row(trainData.n_rows - 1); - trainData.shed_row(trainData.n_rows - 1); - - arma::mat trainLabels1 = arma::zeros(3, trainData.n_cols); - for (size_t i = 0; i < trainData.n_cols; i++) - { - trainLabels1.col(i).row((trainLabels(i) - 1)) = 1; - } - - arma::mat testData; - if (!data::Load("thyroid_test.csv", testData)) - FAIL("Cannot open thyroid_test.csv"); - - arma::mat testLabels = testData.row(testData.n_rows - 1); - testData.shed_row(testData.n_rows - 1); - - /* - * Construct a feed forward network with trainData.n_rows input nodes, - * hiddenLayerSize hidden nodes and trainLabels.n_rows output nodes. The - * network structure looks like: - * - * Input RBF Activation Output - * Layer Layer Layer Layer - * +-----+ +-----+ +-----+ +-----+ - * | | | | | | | | - * | +------>| +------>| +------>| | - * | | | | | | | | - * +-----+ +--+--+ +-----+ +-----+ - */ - arma::mat centroids; - KMeans<> kmeans; - kmeans.Cluster(trainData, 8, centroids); - - FFN model; - model.Add(8, centroids); - model.Add(3); - - // RBFN neural net with MeanSquaredError. - TestNetwork<>(model, trainData, trainLabels1, testData, testLabels, 10, 0.1); - - arma::mat dataset; - dataset.load("mnist_first250_training_4s_and_9s.arm"); - - // Normalize each point since these are images. - for (size_t i = 0; i < dataset.n_cols; ++i) - { - dataset.col(i) /= norm(dataset.col(i), 2); - } - - arma::mat labels = arma::zeros(1, dataset.n_cols); - labels.submat(0, labels.n_cols / 2, 0, labels.n_cols - 1).fill(1); - - arma::mat labels1 = arma::zeros(2, dataset.n_cols); - - for (size_t i = 0; i < dataset.n_cols; ++i) - { - labels1.col(i).row(labels(i)) = 1; - } - labels += 1; - - arma::mat centroids1; - arma::Row assignments; - KMeans<> kmeans1; - kmeans1.Cluster(dataset, 140, centroids1); - - FFN model1; - model1.Add(140, centroids1, 4.1); - model1.Add(2); - - // RBFN neural net with MeanSquaredError. - TestNetwork<>(model1, dataset, labels1, dataset, labels, 10, 0.1); -}