0

我正在尝试读取 MNIST 数据集(大小为 784*60000)我读取 MNIST 二进制格式的实现大约需要 20 秒,但我尝试使用 Matio 库以 .mat 格式读取相同的数据集,并且需要更长的时间约4~5分钟。这就是我尝试读取 mat 文件的方式。难道我做错了什么?

矩阵结构

struct Matrix {
size_t col;
size_t row;
float *members;

Matrix() {
  members = NULL;
  col = 0;
  row = 0;
}
};

读取mat文件

mat_t *openmatfp;
matvar_t *mymat;
Matrix matrix;
openmatfp = Mat_Open("trainingdata.mat",MAT_ACC_RDONLY);
matrix.row = mymat->dims[0];
matrix.col = mymat->dims[1];
matrix.elements = new float[matrix.row * matrix.col];
memcpy(matrix.members, mymat->data,mymat->nbytes);//problem should be here!
4

1 回答 1

0

您显示的代码没有设置 mymat。

你需要类似的东西: mymat = Mat_VarRead(openmatfp, "MatrixName");

于 2014-10-09T07:17:51.997 回答