Search code examples
deep-learningeigen

3D tensor for Deep Learning : Use a MatrixXd<ArrayXd, Dynamic, Dynamic>


I currently use Eigen to do deep learning, and more specifically convolutional neural networks.

You can see an example here : https://en.wikipedia.org/wiki/Convolutional_neural_network#/media/File:Typical_cnn.png

As each step, a layer could be a convolutional layer (a set of features map), a fully connected layer (a single one-dimensional vector) or anything else.

So I choose MatrixX<ArrayXd, Dynamic, Dynamic> to represent my datas.

But when I use it (with matrix product) I have segfaults.

I'm not sure but I think because ArrayXd is not a good scalar type for MatrixX.

Can I use ArrayXd as scalar in Eigen ?

If the answer is no, what can I do ?


Solution

  • ArrayXd is not a good choice to be a scalar type, especially when you want a tensor.

    Eigen has tensor support in its dev-branch/v3.3-bata1. You could find the document here.

    http://eigen.tuxfamily.org/index.php?title=Tensor_support

    https://bitbucket.org/eigen/eigen/src/fefbb833ed5442fb21292bdaa3320543868e41b8/unsupported/Eigen/CXX11/src/Tensor/?at=default#markdown-header-eigen-tensors

    https://eigen.tuxfamily.org/dox-devel/unsupported/group__CXX11__Tensor__Module.html