```python
import sympy as sp
```


```python
x = sp.symbols('x') 
expr = x**2 - x + 1
diff = sp.Derivative(expr, x)
diff
```




$\displaystyle \frac{d}{d x} \left(x^{2} - x + 1\right)$




```python
diff.doit()
```




$\displaystyle 2 x - 1$



At the minimum: $x = \frac{1}{2}$

Function value at at minimum:


```python
0.5**2-0.5+1
```




    0.75




```python
import numpy as np
import tensorflow as tf
```


```python
tf.__version__
```




    '1.14.0'




```python
A = tf.placeholder(tf.float32)
v = tf.placeholder(tf.float32)
op = tf.matmul(A,v)
```


```python
with tf.Session() as session:
    output = session.run(op, feed_dict={A:np.random.random((3,3)),v:np.random.random((3,1))})
```


```python
print(output)
```

    [[0.6251757 ]
     [0.98640007]
     [0.24678826]]



```python
u = tf.Variable(20.0)
```


```python
func = u*u - u + 1
```


```python
opt = tf.train.GradientDescentOptimizer(0.22).minimize(func)
```


```python
init = tf.global_variables_initializer()
```


```python
with tf.Session() as session:
    session.run(init)
    for i in range(15):
        minimum = session.run(opt)
        print("iteration: %d - func_value: %.2f - u_value: %0.2f" % (i, func.eval(), u.eval()))
```

    iteration: 0 - func_value: 120.00 - u_value: 11.42
    iteration: 1 - func_value: 38.15 - u_value: 6.62
    iteration: 2 - func_value: 12.48 - u_value: 3.92
    iteration: 3 - func_value: 4.43 - u_value: 2.42
    iteration: 4 - func_value: 1.90 - u_value: 1.57
    iteration: 5 - func_value: 1.11 - u_value: 1.10
    iteration: 6 - func_value: 0.86 - u_value: 0.84
    iteration: 7 - func_value: 0.79 - u_value: 0.69
    iteration: 8 - func_value: 0.76 - u_value: 0.61
    iteration: 9 - func_value: 0.75 - u_value: 0.56
    iteration: 10 - func_value: 0.75 - u_value: 0.53
    iteration: 11 - func_value: 0.75 - u_value: 0.52
    iteration: 12 - func_value: 0.75 - u_value: 0.51
    iteration: 13 - func_value: 0.75 - u_value: 0.51
    iteration: 14 - func_value: 0.75 - u_value: 0.50


0a2fb856242f7943642336324a58b667cda7ec68
ipynb
Jupyter Notebook
DeepLearning/Tensorflow test.ipynb
CaioMar/dsutils
9975dc7afecd077de9c076470f941eb605e47c4f
MIT
2020-03-16T08:58:47.000Z
2020-03-16T08:58:47.000Z
DeepLearning/Tensorflow test.ipynb
CaioMar/dsutils
9975dc7afecd077de9c076470f941eb605e47c4f
MIT
DeepLearning/Tensorflow test.ipynb
CaioMar/dsutils
9975dc7afecd077de9c076470f941eb605e47c4f
MIT
Qwen/Qwen-72B
1. YES
2. YES