필터 지우기
필터 지우기

How can I speed up spliting a matrix into submatricies?

조회 수: 1 (최근 30일)
J Krause
J Krause 2020년 10월 28일
댓글: Walter Roberson 2020년 10월 28일
I am working on a back propagation assignment and am running into high epoch times for large training samples. I think that how I am storing and accessing the weight and bias matricies is one of the leading causes.
For storing the overall weights during training, I have two matricies of doubles whose size is dependent on the network specs. For the current configuration, the weight matrix is 400x1184 entries and the bias matrix is 400x2 entries. These matricies consist, each, of two smaller matricies, [w1,w2], [b1,b2], with the unused space filled with zeros (since size(w1) ~= size(w2)).
During training, I extract the individual weight matricies from the newly calculated wC and wB matricies via
w = wC(1:rows,offset+1:cols+offset);
b = bC(1:rows,i);
where wC,wB are the composite matricies and rows, cols, offset are variables that define the current size and position of the submatricies within wC and bC. This operation occurs twice per training sample for this network, once for w1 and once for w2. Each time an output matrix is calculated from w and b, but w and b is not directly calculated upon. The operation above takes just about 0.0009s to complete.
My problem is what happens to the execution time when I have 60,000 training samples, when the time component of that operation swells to over 54 seconds. I drastically need to reduce this.
Is there a more time efficent way to split or index these matricies so as to reduce cycle time?
Note that I cannot use existing machine learning libraries on this assignment.
Thanks
  댓글 수: 5
J Krause
J Krause 2020년 10월 28일
Is there a fast function that can split a matrix according to an array of indices? Split a 4,6 and a 2,2 matrix from a 4,8 matrix, for example.
If not, then I would need to extract the matricies in a loop with repeated calls to the composite matrix, or essentially the same thing as I am doing now.
Which brings me to a followup question: Would a cell array of matricies be faster from an indexing perspective than splitting arrays?
Walter Roberson
Walter Roberson 2020년 10월 28일
No there is no routine to do fast splitting. mat2cell and num2cell just loop.

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

답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by