■ 미분 계수를 구하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import tensorflow as tf xTensor = tf.placeholder(tf.float32) yTensor = 2 * xTensor * xTensor differentialCoefficientList = tf.gradients(yTensor, xTensor) with tf.Session() as session: differentialCoefficient = session.run(differentialCoefficientList, feed_dict = { xTensor : 1 }) print(differentialCoefficient) [결과] [4.0] |