Created
February 12, 2019 16:34
-
-
Save Robofied/67951bdb24ef5884f7976670cc3ac3ac to your computer and use it in GitHub Desktop.
Numpy Library
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
#Import Numpy in Python | |
import numpy as np | |
a = np.random.rand(5,1) | |
print(a) | |
#[Output]: | |
#[[0.28642857] | |
# [0.51330181] | |
# [0.92992345] | |
# [0.27376296] | |
# [0.21996422]] | |
## Show how much time vectorized version take for calculation | |
import time | |
a = np.random.rand(1000000) | |
b = np.random.rand(1000000) | |
tic = time.time() | |
c = np.dot(a,b) | |
toc = time.time() | |
print("Vectorized Version " + str(1000*(toc-tic)) + "ms") | |
#[Output]: | |
#Vectorized Version 0.0ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment