<jupyter_start><jupyter_text>HW 1 Answer folloing questions using tensorflow's gradient tape.  EX)```input_var = tf.Variable(initial_value=3.)with tf.GradientTape() as tape:   result = tf.square(input_var)gradient = tape.gradient(result, input_var)``` Q1 Differentiate $y = x^2 + 3x + 1$ with respect to a scalar variable $x$.<jupyter_code>import tensorflow as tf
import numpy
x = tf.Variable(0.)
with tf.GradientTape() as tape:
  y = x**2 + 3*x + 1
dy_dx = tape.gradient(y,x)
dy_dx.numpy()<jupyter_output><empty_output><jupyter_text>Q2 Differentiate $y = X^3 + 3X + 5$ with respect to a 2 by 2 matrix variable $X$.<jupyter_code>X = tf.Variable(tf.random.uniform([2,2]))
with tf.GradientTape() as tape:
  y = X**3 + 3*X + 5
dy_dX = tape.gradient(y,X)
dy_dX
print('shape of X :', X.shape)
print('shape of dy_dX :', dy_dX.shape)<jupyter_output>shape of X : (2, 2)
shape of dy_dX : (2, 2)<jupyter_text>Q3 Differentiate $z = X^3 y^2 + 3X + 2xy + 1$ with respect to a 2 by 2 matrix variable $X$ and a scalar variable $y$.<jupyter_code>y = tf.Variable(1.)
X = tf.Variable(tf.random.uniform([2,2]))
with tf.GradientTape() as tape:
  z = X**3 * y**2 + 3*X + 2*X*y + 1
dz_dX_and_dy = tape.gradient(z ,[X,y])
# result
print("dz_dX :" ,dz_dX_and_dy[0])
print("dz_dy :" ,dz_dX_and_dy[1].numpy())<jupyter_output>dz_dX : tf.Tensor(
[[5.228007  5.01523  ]
 [5.0917144 5.9727845]], shape=(2, 2), dtype=float32)
dz_dy : 2.60506
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.05815602836879433, 'mean_word_length': 5.02991452991453, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '289291', 'license': 'Apache-2.0', 'n_tokens_mistral': 659, 'n_tokens_neox': 592, 'n_words': 146, 'path': 'assignment/HW1.ipynb', 'repo_name': 'JuneSHYoo/AI_DeepLearning', 'size': '1410'}