Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::logic_error when copying model #239

Open
CyberShadow opened this issue Oct 3, 2024 · 0 comments
Open

std::logic_error when copying model #239

CyberShadow opened this issue Oct 3, 2024 · 0 comments

Comments

@CyberShadow
Copy link

If I take the lstm_electricity_consumption.cpp example and modify it like

diff --git a/ml/test.cpp b/ml/test.cpp
index f7ce54b..53e2255 100644
--- a/ml/test.cpp
+++ b/ml/test.cpp
@@ -208,12 +208,12 @@ int main()
   // Create test sets for one-step-ahead regression.
   CreateTimeSeriesData(testData, testX, testY, rho);
 
+  // RNN regression model.
+  RNN<MeanSquaredError, HeInitialization> model(rho);
+
   // Only train the model if required.
   if (bTrain || bLoadAndTrain)
   {
-    // RNN regression model.
-    RNN<MeanSquaredError, HeInitialization> model(rho);
-
     if (bLoadAndTrain)
     {
       // The model will be trained further.
@@ -263,9 +263,6 @@ int main()
                 EarlyStopAtMinLoss());
 
     cout << "Finished training." << endl;
-    cout << "Saving Model" << endl;
-    data::Save(modelFile, "LSTMUnivar", model);
-    cout << "Model saved in " << modelFile << endl;
   }
 
   // NOTE: the code below is added in order to show how in a real application
@@ -275,9 +272,7 @@ int main()
   // before.  In your own application you may of course load any dataset.
 
   // Load RNN model and use it for prediction.
-  RNN<MeanSquaredError, HeInitialization> modelP(rho);
-  cout << "Loading model ..." << endl;
-  data::Load(modelFile, "LSTMUnivar", modelP);
+  auto modelP = model;
   arma::cube predOutP;
 
   // Get predictions on the test data points.

then the program crashes with

Finished training...........................................................................................] 6% - ETA: 0s - loss: 0.00364827
terminate called after throwing an instance of 'std::logic_error'
  what():  arma::memory::acquire(): requested size is too large
Aborted (core dumped)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant