0
FFN<> model;
model.Add<Linear<> >(trainData.n_rows, 12);
model.Add<LeakyReLU<> >(0.1);
model.Add<BatchNorm<> >(12);
model.Add<Dropout<> >(0.3);
model.Add<Linear<> >(12, 8);
model.Add<PReLU<> >();
model.Add<BatchNorm<> >(8);
model.Add<Dropout<> >(0.3);
model.Add<Linear<> >(8,3);
model.Add<BatchNorm<> >(3);
model.Add<PReLU<> >();
model.Add<Dropout<> >(0.3);
model.Add<LogSoftMax<> >();

cout<< "Data Print!" << endl;
trainData.brief_print();
trainLabel.brief_print();
testData.brief_print();
testLabel.brief_print();
arma::mat uniqueTrain = unique(trainLabel);
uniqueTrain.print();
try{
    ens::Adam optimizer(
           5e-4,// Step size of the optimizer.
           64, // Batch size. Number of data points that are used in each iteration.
           0.9,// Exponential decay rate for the first moment estimates.
           0.999, // Exponential decay rate for the weighted infinity norm estimates.
           1e-8,  // Value used to initialise the mean squared gradient parameter.
           100, // Max number of iterations.
           1e-8,// Tolerance.
           true);
     model.Train(trainData, trainLabel,ens::PrintLoss(),
     ens::ProgressBar());
            // Stop the training using Early Stop at min loss.
            //   ens::EarlyStopAtMinLoss(
            //       [&](const arma::mat& /* param */)
            //       {
            //         double validationLoss = model.Evaluate(validX, validY);
            //         std::cout << "Validation loss: " << validationLoss
            //             << "." << std::endl;
            //         return validationLoss;
            //       }
        }
catch (const out_of_range& e) {
     std::cerr << "Out of range error: " << e.what() << endl; 
}
cout << "Model generated." << endl;
arma::mat predictionTemp;
model.Predict(testData,predictionTemp);
arma::mat prediction = arma::zeros<arma::mat>(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;
}
prediction.brief_print();
unique(prediction).brief_print();
data::Save("AgriModel.xml","AgriModel",model,false); // I remove and this compiles fine with proper output.

仅当我尝试保存上述模型时才会出现此问题。其他一切运行良好。

g++ -Ofast -Iboost/include -Imlpack/include/ -Iarmadillo/include -Lboost/lib -Lmlpack/lib/ -Larmadillo/lib -std=c++2a SignatureAnalysis.cpp  -lm -lmlpack -larmadillo -fopenmp -w -o SignatureAnalysis.out 2> linkererror.txt

关于 mlpack。它与所有依赖项一起编译,但由于某种原因,上述语句仍使用标准位置的库。很好,我已经通过 安装了每个库apt,即使我已经从头开始重新编译它们(上面的每个链接库)。

我得到的错误是

ZeroBin 链接错误

Github 错误要点

4

0 回答 0