mirror of
https://github.com/autistic-symposium/tensorflow-for-deep-learning-py.git
synced 2025-05-12 11:42:14 -04:00
👾 Add some machine learning experiments
This commit is contained in:
parent
cab89257dd
commit
729da96322
60 changed files with 39649 additions and 0 deletions
60
machine_learning_examples/numpy_examples/README.md
Normal file
60
machine_learning_examples/numpy_examples/README.md
Normal file
|
@ -0,0 +1,60 @@
|
|||
## Numpy Resources
|
||||
|
||||
### Arrays
|
||||
|
||||
* Grid of values, all of the same type.
|
||||
* The number of dimensions is the rank of the array.
|
||||
* The shape of an array is a tuple of integers giving the size of the array along each dimension.
|
||||
|
||||
|
||||
```
|
||||
a = np.array([1, 2, 3]) # Create a rank 1 array
|
||||
print a.shape # Prints "(3,)"
|
||||
```
|
||||
|
||||
```
|
||||
numpy.asarray([])
|
||||
numpy.asarray([]).shape
|
||||
```
|
||||
|
||||
|
||||
* Many functions to create arrays:
|
||||
|
||||
```
|
||||
a = np.zeros((2,2)) # Create an array of all zeros
|
||||
b = np.ones((1,2)) # Create an array of all ones
|
||||
c = np.full((2,2), 7) # Create a constant array
|
||||
d = np.eye(2) # Create a 2x2 identity matrix
|
||||
e = np.random.random((2,2)) # Create an array filled with random values
|
||||
```
|
||||
|
||||
* Products:
|
||||
|
||||
|
||||
```
|
||||
x = np.array([[1,2],[3,4]])
|
||||
|
||||
v = np.array([9,10])
|
||||
w = np.array([11, 12])
|
||||
|
||||
# Inner product of vectors
|
||||
print v.dot(w)
|
||||
print np.dot(v, w)
|
||||
|
||||
# Matrix / vector product
|
||||
print x.dot(v)
|
||||
print np.dot(x, v)
|
||||
```
|
||||
|
||||
* Sum:
|
||||
|
||||
```
|
||||
print np.sum(x) # Compute sum of all elements
|
||||
print np.sum(x, axis=0) # Compute sum of each column
|
||||
print np.sum(x, axis=1) # Compute sum of each row
|
||||
```
|
||||
|
||||
* Broadcasting is a mechanism that allows numpy to work with arrays of different shapes when performing arithmetic operations. Frequently we have a smaller array and a larger array, and we want to use the smaller array multiple times to perform some operation on the larger array.
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue