Created
January 20, 2015 12:45
-
-
Save denizyuret/b2bbe126562c84725059 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Here is our weight matrix: | |
>> w=randn(20000,1000); | |
% Here is our instance: | |
>> x=randn(1000,1); | |
% Try multiplying them on cpu: | |
>> tic; for i=1:10000 y=w*x; end; toc; | |
Elapsed time is 59.851655 seconds. | |
% Try multiplying them on gpu: | |
>> gw = gpuArray(w); | |
>> gx = gpuArray(x); | |
>> tic; for i=1:10000 gy=gw*gx; end; wait(gpuDevice); toc; | |
Elapsed time is 13.150812 seconds. | |
% Let's try mini-batches of 100 instances: | |
>> x100=randn(1000,100); | |
% Try multiplying them on cpu: | |
>> tic; for i=1:100 y=w*x100; end; toc; | |
Elapsed time is 4.554871 seconds. | |
% Try multiplying them on gpu: | |
>> gx100 = gpuArray(x100); | |
>> tic; for i=1:100 gy=gw*gx100; end; wait(gpuDevice); toc; | |
Elapsed time is 0.594685 seconds. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment