Matio表现

时间:2014-01-17 08:01:34

标签: mat-file mnist

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

Matrix struct

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!

1 个答案:

答案 0 :(得分:0)

您显示的代码未设置mymat。

你需要这样的东西:  mymat = Mat_VarRead(openmatfp,“MatrixName”);