Skip to content

Instantly share code, notes, and snippets.

💭
Towards Singularity

Robofied Robofied

💭
Towards Singularity
Block or report user

Report or block Robofied

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View numpy_linear_algebra2.py
## Working same as np.dot()
np.matmul([[2,3],[3,4]],[[1,2],[5,6]])
#[Output]:
#array([[17, 22],
# [23, 30]])
## Here matmul will automatically brodcast if dimensiona are not same
np.matmul([[1, 0], [0, 1]],[1,2])
View numpy_linear_algebra1.py
##importing libraries
import numpy.linalg as lnp
import numpy as np
## dot product for simple numbers.
np.dot(3,4)
#[Output]:
#12
View numpy_copies_views3.py
## Creating a new array.
e = np.array([21,22,23])
## Creating a new array by using copy function.
f = e.copy()
## Checking the ids of both arrays
#3 In this case also both will have different idsIn [13]:
print(id(e))
View numpy_copies_views2.py
## Creating a new array
c = np.array([11,12,13])
## Creating another array using view function
d = c.view()
## Checking the value of "d"
print(d)
#[Output]:
View numpy_copies_views1.py
## Importing numpy library for creating numpy
import numpy as np
## Creating a 1-D array
a = np.array([0,2,1])
print(a)
#[Output]:
#array([0, 2, 1])
View numpy_sort_search2.py
## Searching
import numpy as np
## 1. argmax()
a = np.arange(6).reshape(2,3)
print(a)
#[Output]:
#[[0 1 2]
View numpy_sort_search1.py
import numpy as np
## 1. sort()
## Sorting along flattened array
a = np.array([[5,4],[3,1]])
np.sort(a)
#[Output]:
#array([[4, 5],
# [1, 3]])
View numpy_sort_search1.py
import numpy as np
## 1. argmax()
a = np.arange(6).reshape(2,3)
print(a)
#[Output]:
#[[0 1 2]
# [3 4 5]]
View numpy_statistical_functions3.py
y= a.mean(axis=1)
print(y)
#[Output]:
#[0.5 2.5 4.5]
y.reshape(3,1)
#[Output]:
View numpy_statistical_functions2.py
import numpy as np
a = np.arange(6).reshape(3,2)
print(a)
#[Output]:
#array([[0, 1],
# [2, 3],
# [4, 5]])
You can’t perform that action at this time.