What's fid in "Training a Model from Scratch"?

조회 수: 2 (최근 30일)
Runcong Kuang
Runcong Kuang 2022년 7월 31일
댓글: Runcong Kuang 2022년 8월 1일
For this DL example,
What's the 'fid' in the first code block?
rawImgDataTrain = uint8 (fread(fid, numImg * numRows * numCols, 'uint8'));
% Reshape the data part into a 4D array
rawImgDataTrain = reshape(rawImgDataTrain, [numRows, numCols, numImgs]);
imgDataTrain(:,:,1,ii) = uint8(rawImgDataTrain(:,:,ii));

채택된 답변

Walter Roberson
Walter Roberson 2022년 7월 31일
rawImgDataTrain = uint8 (fread(fid, numImg * numRows * numCols, 'uint8'));
In this context, fid would be
fid = fopen('Some_MNIST_file_name_goes_here');
That is, it is a "file identifier" returned by fopen() when you ask to open one of the MNIST files.
numImg and numRows and numCols would all have to be known ahead of time, some-how. Perhaps there is a header file that contains those values.
The fread() call would read binary data, one unsigned 8-bit integer per entry. The number of entries to read is numImg * numRows * numCols . The uint8() call would not be necessary if the line had been properly coded as
rawImgDataTrain = fread(fid, numImg * numRows * numCols, '*uint8');
  댓글 수: 1
Runcong Kuang
Runcong Kuang 2022년 8월 1일
Cool. But I really want to know what exactly is the mnist file here.
I download the .gz files and don't know what to do with them.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Atsushi Ueno
Atsushi Ueno 2022년 7월 31일
> What's the 'fid' in the first code block?
It is fileID — File identifier of an open file
When you open the file by fopen function, you can get the ID number.
You need the ID number to access the opened file by fread function or something else.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by