역전파(Back Propagation )를 진행 하기 위해서 순전파(Forward Propagation)의 과정이 저장 되어 있어야 하기 때문에 연산 내역을 저장해 놓는 Tape를 만들어 놓는다고 생각 하면 된다.

model에서 뿐만 아니라 loss를 계산 한 내용을 저장 해 놓는다.

import tensorflow as tf
import matplotlib.pyplot as plt

t1 = tf.Variable([1, 2, 3], dtype = tf.float32)
t2 = tf.Variable([10, 20, 30], dtype = tf.float32)

with tf.GradientTape() as tape:
	# t3를 t1과 t2를 통해 만든다.
	t3 = t1 * t2

# 만든 t3를 t1과 t2에 대한 편미분을 저장한다.
gradients = tape.gradient(t3, [t1, t2])
# type은 list 형식이다.
print(gradients)
# t1, t2에 대한 편미분
print('dt1 : ', gradients[0])
print('dt2 : ', gradients[1])