코드 3-12 그레이디언트 테이프를 중첩하여 이계도 그레이디언트 계산하기
time = tf.Variable(0.) with tf.GradientTape() as outer_tape: with tf.GradientTape() as inner_tape: position = 4.9 * time ** 2 speed = inner_tape.gradient(position, time) acceleration = outer_tape.gradient(speed, time) ----- 바깥쪽 테이프가 안쪽 테이프의 그레이디언트를 계산합니다. 계산된 가속도는 4.9 * 2 = 9.8입니다.