I want to do whats written in the title, I have tried following code:
typedef std::vector<std::vector<std::vector<double>>> Tensor;
// should return a matrix of shape (batch_size, 1840)
Eigen::MatrixXd flatten(Tensor x)
{
int channels = x.size(); // always 10
int batch = x[0].size(); // varies
int columns = x[0][0].size(); // always 184
Eigen::Matrix<double, Eigen::Dynamic, 1840> matrix;
for (unsigned int b = 0; b < batch; b++)
{
for (unsigned int i = 0; i < columns; i++)
{
for (unsigned int c = 0; c < channels; c++)
{
matrix << x[c][b][i]; // I also tried this: matrix(b, i+c) = x[c][b][i];
}
}
}
return matrix;
}
But the code either aborts with abort() has been called
message or its giving me an Access violation writing location 0x0000000000000000
Whats the proper way to accomplish what I am trying to do?