Registered Member
|
Hello
I am building a class that represents an Autoencoder. You can think about it as a neural network with one input layer, one hidden layer and one output layer. Basically I have a VectorXd theta of parameters, but I want to interpret different parts of it as matrices of parameters between layers. In other words I have parameters unrolled in a vector, and want to have maps on the same place in memory, to be able to use that data as it were in a MatrixXd, so I can I tried to have a few Map<MatrixXd> and Map<VectorXd> members in class :
but the compiler doesn't allow me to do it. I managed to do the trick by using const references to Map<MatrixXd> objects and initializing them in constructor, and then removing constness with const_cast<>. However I would like to be able to have just Map<MatrixXd> objects as class members, and initialize them in a way that won't invoke memory allocator. The current way may work, but it doesn't solve the problem of building a neural network when the number of layers is unknown ( i can't initalize unknown number of references in constructor). Please help, I especially don't get it why I can't hace Map<MatrixXd> objects as members. |
Registered Member
|
It's hard to know what your problem is without some more details. It may be caused by the fact that the Map class does not have a default initializer. In that case, you can initialize the Map class with a null pointer and then use the placement new operator to have it point wherever you want it do point. See the last example in the tutorial page on the Map class: http://eigen.tuxfamily.org/dox/TutorialMapClass.html .
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]