problem in this code
古いコメントを表示
hi,
I have ran this code since more than 4 hours ,and did not complete yet. where is the problem ?
I read 1000 files, but the running time in unreasonable:
%%%%%%%%%%%%%%%%%%5
arr1=sparse(1000,232944);
targetdir = 'd:\social net\dataset\netflix\netflix_2\training_set';
%%nofusers=480189
targetfiles = '*.txt';
fileinfo = dir(fullfile(targetdir, targetfiles));
for i = 1:1000
thisfilename = fullfile(targetdir, fileinfo(i).name);
f = fopen(thisfilename,'r');
c = textscan(f, '%f %f %s', 'Delimiter', ',', 'headerLines', 1);
fclose(f);
c1=sparse(length(c));c2=sparse(length(c1));c3=sparse(length(c));
c1 = c{1};
c3=c{3};
L(i)=length(c1);
format long
dat=round(datenum(c3,'yyyy-mm-dd'));
arr=[c1 dat];
arr1(i,1:L(i)*2)=reshape(arr.',1,[]);
end
10 件のコメント
Fangjun Jiang
2011 年 11 月 22 日
Please format your code.
Image Analyst
2011 年 11 月 22 日
Put disp(i) in the loop and see how many i's it prints out to the command line. You might also see if the printouts start to slow down as the count gets higher.
huda nawaf
2011 年 11 月 23 日
huda nawaf
2011 年 11 月 23 日
huda nawaf
2011 年 11 月 23 日
Image Analyst
2011 年 11 月 23 日
No, "f" is the id of the file. "i" is your loop counter. So it just slows down more and more at each iteration until it finally grinds to a halt? I can't really help much since I don't have your files. How big does i get before it take more than about 5 seconds per iteration? Why do you need to reshape arr? Why can't you just construct it in the correct shape to begin with?
the cyclist
2011 年 11 月 23 日
I have not looked at your code in detail, but is it possible that as your code runs, you are using more and more memory? Maybe after a while, you are starting to use virtual memory, which will slow everything down dramatically. You can monitor that.
huda nawaf
2011 年 11 月 23 日
huda nawaf
2011 年 11 月 23 日
Daniel Shub
2011 年 11 月 23 日
Formatting doesn't work in comments (but thanks for trying).
採用された回答
その他の回答 (1 件)
Daniel Shub
2011 年 11 月 23 日
I would try replacing
arr1=sparse(1000,232944);
with
arr1 = cell(1000, 1);
and
arr1(i,1:L(i)*2)=reshape(arr.',1,[]);
with
arr1{i} = reshape(arr.',1,[]);
カテゴリ
ヘルプ センター および File Exchange で Parallel Computing Fundamentals についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!