<filename>ai-programming/ai_book_code/dl_step7_1.py<gh_stars>0
import tensorflow as tf

# 자동미분 계산!

x = tf.Variable(2.0)  # tf.Variable(2.0, trainable=True)
y = tf.Variable(3.0)  # tf.Variable(3.0, trainable=True)

with tf.GradientTape() as tape:
    z = x ** 2 + y ** 2
dx, dy = tape.gradient(z, [x, y])

print('dx=', dx.numpy())
print('dy=', dy.numpy())

<filename>ai-programming/ai_book_code/dl_step7_1.py<gh_stars>0
import tensorflow as tf

# 자동미분 계산!

x = tf.Variable(2.0)  # tf.Variable(2.0, trainable=True)
y = tf.Variable(3.0)  # tf.Variable(3.0, trainable=True)

with tf.GradientTape() as tape:
    z = x ** 2 + y ** 2
dx, dy = tape.gradient(z, [x, y])

print('dx=', dx.numpy())
print('dy=', dy.numpy())

# 자동미분 계산! # tf.Variable(2.0, trainable=True) # tf.Variable(3.0, trainable=True)