import sys

sys.path.insert(0, "../")
import symjax
import symjax.tensor as T

# create our variable to be optimized
mu = T.Variable(T.random.normal((), seed=1))

# create our cost
cost = T.exp(-((mu - 1) ** 2))

# get the gradient, notice that it is itself a tensor that can then
# be manipulated as well
g = symjax.gradients(cost, mu)
print(g)

# (Tensor: shape=(), dtype=float32)

# create the compield function that will compute the cost and apply
# the update onto the variable
f = symjax.function(outputs=cost, updates={mu: mu - 0.2 * g})

for i in range(10):
    print(f())

# 0.008471076
# 0.008201109
# 0.007946267
# 0.007705368
# 0.0074773384
# 0.007261208
# 0.0070561105
# 0.006861261
# 0.006675923
# 0.006499458

831f57de9d19676b05c8faa4656ba599f9a7b0ef
<mask token>

<mask token>
sys.path.insert(0, '../')
<mask token>
print(g)
<mask token>
for i in range(10):
    print(f())

<mask token>
sys.path.insert(0, '../')
<mask token>
mu = T.Variable(T.random.normal((), seed=1))
cost = T.exp(-(mu - 1) ** 2)
g = symjax.gradients(cost, mu)
print(g)
f = symjax.function(outputs=cost, updates={mu: mu - 0.2 * g})
for i in range(10):
    print(f())

import sys
sys.path.insert(0, '../')
import symjax
import symjax.tensor as T
mu = T.Variable(T.random.normal((), seed=1))
cost = T.exp(-(mu - 1) ** 2)
g = symjax.gradients(cost, mu)
print(g)
f = symjax.function(outputs=cost, updates={mu: mu - 0.2 * g})
for i in range(10):
    print(f())

import sys

sys.path.insert(0, "../")
import symjax
import symjax.tensor as T

# create our variable to be optimized
mu = T.Variable(T.random.normal((), seed=1))

# create our cost
cost = T.exp(-((mu - 1) ** 2))

# get the gradient, notice that it is itself a tensor that can then
# be manipulated as well
g = symjax.gradients(cost, mu)
print(g)

# (Tensor: shape=(), dtype=float32)

# create the compield function that will compute the cost and apply
# the update onto the variable
f = symjax.function(outputs=cost, updates={mu: mu - 0.2 * g})

for i in range(10):
    print(f())

# 0.008471076
# 0.008201109
# 0.007946267
# 0.007705368
# 0.0074773384
# 0.007261208
# 0.0070561105
# 0.006861261
# 0.006675923
# 0.006499458
