How can I speed up spliting a matrix into submatricies?
2 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 28 Oct 2020
No there is no routine to do fast splitting. mat2cell and num2cell just loop.
Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!