What is the reason for this code to go out of memory?

2 次查看(过去 30 天)
filename= 'train_images_idx3_ubyte';
imgs=[];
readdigit =60000
% Read digits % This program reads 60000 binary image
fid = fopen(filename, 'r','b');
offset= fread(fid, 4, 'int32');
imgs = fread(fid,inf, 'uchar');
imgs = transpose(reshape(imgs,28*28,readdigits));
fclose(fid);
In this code,if i didnt use transpose in line 7, it shows out of memory. I have 1.8 terabyte of memory. Then y it shows out of memory. If i use transpose, it goes good. Whats the reason?

回答(1 个)

Image Analyst
Image Analyst 2014-9-10
You're trying to reshape whatever you read in into a 784 (=28*28) row by 60 thousand column matrix. Why, when you only have 60 thousand numbers?
When you first get imgs, what does this say
whos imgs
Type memory on the command line and paste what you see back here.
>> memory

类别

Help CenterFile Exchange 中查找有关 Software Development Tools 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by