| |
| filename='trial.h5'; |
|
|
| num_total_samples=10000; |
| |
| data_disk=rand(5,5,1,num_total_samples); |
| label_disk=rand(10,num_total_samples); |
|
|
| chunksz=100; |
| created_flag=false; |
| totalct=0; |
| for batchno=1:num_total_samples/chunksz |
| fprintf('batch no. %d\n', batchno); |
| last_read=(batchno-1)*chunksz; |
|
|
| |
| batchdata=data_disk(:,:,1,last_read+1:last_read+chunksz); |
| batchlabs=label_disk(:,last_read+1:last_read+chunksz); |
|
|
| |
| startloc=struct('dat',[1,1,1,totalct+1], 'lab', [1,totalct+1]); |
| curr_dat_sz=store2hdf5(filename, batchdata, batchlabs, ~created_flag, startloc, chunksz); |
| created_flag=true; |
| totalct=curr_dat_sz(end); |
| end |
|
|
| |
| h5disp(filename); |
|
|
| |
|
|
| |
| data_rd=h5read(filename, '/data', [1 1 1 1000], [5, 5, 1, 1000]); |
| label_rd=h5read(filename, '/label', [1 1000], [10, 1000]); |
| fprintf('Testing ...\n'); |
| try |
| assert(isequal(data_rd, single(data_disk(:,:,:,1000:1999))), 'Data do not match'); |
| assert(isequal(label_rd, single(label_disk(:,1000:1999))), 'Labels do not match'); |
|
|
| fprintf('Success!\n'); |
| catch err |
| fprintf('Test failed ...\n'); |
| getReport(err) |
| end |
|
|
| |
|
|
| |
| FILE=fopen('list.txt', 'w'); |
| fprintf(FILE, '%s', filename); |
| fclose(FILE); |
| fprintf('HDF5 filename listed in %s \n', 'list.txt'); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|