GiorgosXou/NeuralNetworks

if you do not define REDUCE_RAM_STATIC_REFERENCE

lewisrichardson2103 opened this issue · 2 comments

Hi again,

If you do not define REDUCE_RAM_STATIC_REFERENCE then you have an issue with const declarations and the pointer to the neural network within the library (*me).

If I run the backprop double_XOR example (I am using a adafruit feather sense) then I get the following error (no changes made to code) :
NeuralNetwork.h:732:18: error: invalid conversion from 'const NeuralNetwork*' to 'NeuralNetwork*' [-fpermissive]
732 | me = NN;
| ^~
| |
| const NeuralNetwork*

if you include a definition for the reduced ram then this issue goes away

Thanks

Lewis

Hello Lewis 👋,

What version of arduino do you use and what version of gcc?

If you are using Arduino's IDE, try going to "file>Preferences", check "compilation" and "Use accessibility features" boxes and then recompile/verify the sketch and post the Output here.

About the "Const" & Issue

To be honest It's not necessary for the library to have const in this specific case of Layer's constructors but it also shouldn't have had an issue with (or so i think) ... anyways most probably i will fix it in the next days [...] Also have you tested compiling it for other boards like Arduino Uno?

About B00010000 aka REDUCE_RAM_STATIC_REFERENCE

Just for information purposes, it doesn't really slows CPU performance (actually it might even make it faster by ~microseconds [i would say] and i think that it uses a bit less ROM in some specific cases too) the reason i've set it by default not to be used is because the only thing that really changes and makes a difference is related to user/programmer's experience (compared to when it's not enabled/used), is just that the user has to use it in an ambiguous way when using multiple networks on the same sketch (because *me is statically referenced and has to be redefined after the use of another network)

PS. Thanks you ❤️ for bringing this issue to my awareness, i had no idea that it existed [...]
(Although it's a weird issue.. i was expecting a warning and no error but whatever lol)

@lewisrichardson2103 I found the issue, I didn't know that i was supposed to use:

Layer(const unsigned int &NumberOfInputs, const unsigned int &NumberOfOutputs, NeuralNetwork * const NN ) //

instead of (what i was using before) :

Layer(const unsigned int &NumberOfInputs, const unsigned int &NumberOfOutputs,  const * NeuralNetwork NN ) // 🚫

for the compiler to translate it into a "const pointer to a NeuralNetwork-Object"

Again thanks you ❤️ for bringing this issue to my awareness [...]