Created
February 15, 2019 19:56
-
-
Save Robofied/900a39ecf356b0bf543841c56ec86d00 to your computer and use it in GitHub Desktop.
Numpy
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
## returning 0's matrix | |
nm.zeros((2,3)) | |
#[Output]: | |
#matrix([[0., 0., 0.], | |
# [0., 0., 0.]]) | |
## it returns diagonal matrix i.e, 1's at diagonal and 0's elsewhere. | |
nm.eye(n=3, M=4, k=-1, dtype='int') | |
#[Output]: | |
#matrix([[0, 0, 0, 0], | |
# [1, 0, 0, 0], | |
# [0, 1, 0, 0]]) | |
##4. rand() | |
## It return the random value | |
nm.rand(2) | |
#[Output]: | |
#matrix([[0.31396025, 0.05886812]]) | |
## Multidimensional matrix | |
nm.rand(2,3) | |
#[Output]: | |
#matrix([[0.866112 , 0.38662401, 0.32563106], | |
# [0.80981318, 0.59824592, 0.85585548]]) | |
## One can also pass the tuple for shape of the output. | |
nm.rand((2,3)) | |
#[Output]: | |
#matrix([[0.27994566, 0.58220104, 0.76714032], | |
# [0.44271856, 0.69717546, 0.16341003]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment