```python
import numpy as np
```


```python
# matrix multiplication
a = np.array([[0,6],[2,8],[4,10]])
b = np.array([[1,3,5],[7,9,11]])
print(a)
print(b)
print(np.dot(a,b))
```

    [[ 0  6]
     [ 2  8]
     [ 4 10]]
    [[ 1  3  5]
     [ 7  9 11]]
    [[ 42  54  66]
     [ 58  78  98]
     [ 74 102 130]]



```python
print(np.matmul(a,b))
```

    [[ 42  54  66]
     [ 58  78  98]
     [ 74 102 130]]



```python
# sigmoid activation function
def sigmoid(x):
    return 1 / (1 + np.exp(-x))
```


```python
x1=1
x2=1
score = 4*x1 + 5*x2 - 9
```


```python
sigmoid(score)
```




    0.5




```python
w1=3
w2=5
b=-2.2

sigmoid(w1*0.4 + w2*0.6 + b)
```




    0.8807970779778823




```python
# eigenvector and eigenvalues
A = np.array([[3, 0],[-9, 6]])
x = np.array([1, 3])

np.dot(A, x)
```




    array([3, 9])




```python
# picture size calculation
#     W  = input volume
#     K  = Kernel size
#     P =  padding
#     S = stride

np.int_(((130-3+0)/1)+1)
```




    128



$[(W−K+2*P)/S]+1$


```python
# calculating padding that has kernel_size of 7 for CNN that is the same x-y size as an input array
# see above equation; using P = 3
x = (-7 + 2*3/1) + 1 # results in zero; W - 0 = W
print(np.int_(x))
```

    0



```python
from sympy import Symbol

Symbol('w') + x == Symbol('w') # W = W; CNN has same x-y size as input array
```




    True




```python
# nlp: Subsampling equation
# text with 1 million words in it
# word "learn" appears 700 times in this text
# threshold is 0.0001
```

$p = 1 - \sqrt{\frac{t}{f(x_[i])}}$


```python
# -> calculate probability that we will discard the word "learn"
f = 700
w_i = 1e6
t = 1e-4
```


```python
p = 1 - np.sqrt(t/(f/w_i))
print(p)
```

    0.6220355269907727



```python
# For an input [23, 702, 89, 15, 99] and R=2, what will the returned context be if we pass in the token at idx=1 (702)?
def get_target(words, idx, R):
    start = idx - R if (idx - R) > 0 else 0
    stop = idx + R
    target_words = words[start:idx] + words[idx+1:stop+1]
    
    return list(target_words)
```


```python
print(get_target(words=[23, 702, 89, 15, 99], idx=1, R=2))
```

    [23, 89, 15]


030884b458bc821f1105ab04f5f87aa476e75fa6
ipynb
Jupyter Notebook
notes.ipynb
d-kleine/Udacity_DLND
36ae9dd851c2e460139d3faf0a5967807c94b85f
MIT
notes.ipynb
d-kleine/Udacity_DLND
36ae9dd851c2e460139d3faf0a5967807c94b85f
MIT
notes.ipynb
d-kleine/Udacity_DLND
36ae9dd851c2e460139d3faf0a5967807c94b85f
MIT
Qwen/Qwen-72B
1. YES
2. YES