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

Exception in mnist_cnn.cpp #183

Closed
AdmiralPellaeon opened this issue Oct 7, 2021 · 5 comments
Closed

Exception in mnist_cnn.cpp #183

AdmiralPellaeon opened this issue Oct 7, 2021 · 5 comments

Comments

@AdmiralPellaeon
Copy link

AdmiralPellaeon commented Oct 7, 2021

I build mlpack with VS2019 x64 for Windows. I also created the needed CSV file with the data with the help of the python script from the tools directory.

I tried to run the "mnist_cnn.cpp" from this repo. Compiling works fine, but during the training an exception is thrown: "error: Mat::operator(): index out of bounds".

This is the call stack until the exception occurs:
grafik

Best regards

@rcurtin
Copy link
Member

rcurtin commented Oct 23, 2021

Hey @AdmiralPellaeon, thanks for the report. What version of mlpack are you compiling against?

@AdmiralPellaeon
Copy link
Author

It's mlpack-3.4.2.

@rcurtin
Copy link
Member

rcurtin commented Oct 26, 2021

Ah, ok, thanks for the information. I think that is the issue. mlpack-3.4.2 is pretty old now but we haven't released mlpack 4 yet because we are in the midst of a big refactoring. If you can download the latest git master branch from https://github.com/mlpack/mlpack and use that and compile the MNIST CNN example against that version, it should work. If you can't, then I think this should fix it, if you change these lines:

  // Create labels for training and validatiion datasets.
  const mat trainY = train.row(0);
  const mat validY = valid.row(0);

to this:

  // Create labels for training and validatiion datasets.
  const mat trainY = train.row(0) + 1;
  const mat validY = valid.row(0) + 1;

Sorry for the inconvenience! I hope we will be able to release and package a new version of mlpack soon (there is still lots of refactoring to do though).

@AdmiralPellaeon
Copy link
Author

Thanks for the answer. I will test it!

@dfy888
Copy link

dfy888 commented Nov 23, 2021

 train.row(0)

Ah, ok, thanks for the information. I think that is the issue. mlpack-3.4.2 is pretty old now but we haven't released mlpack 4 yet because we are in the midst of a big refactoring. If you can download the latest git master branch from https://github.com/mlpack/mlpack and use that and compile the MNIST CNN example against that version, it should work. If you can't, then I think this should fix it, if you change these lines:

  // Create labels for training and validatiion datasets.
  const mat trainY = train.row(0);
  const mat validY = valid.row(0);

to this:

  // Create labels for training and validatiion datasets.
  const mat trainY = train.row(0) + 1;
  const mat validY = valid.row(0) + 1;

Sorry for the inconvenience! I hope we will be able to release and package a new version of mlpack soon (there is still lots of refactoring to do though).

yes,it is work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants