<jupyter_start><jupyter_text>Import *autograd*<jupyter_code>import mxnet as mx
from mxnet import nd
from mxnet import autograd<jupyter_output><empty_output><jupyter_text>Calculate derivative of f(x) = 2x2<jupyter_code>x = nd.array([[1, 2],[3, 4]])
x
x.attach_grad()
def f(x):
    return 2 * x**2
with autograd.record():
    y = f(x)
x, y
y.backward()
x, x.grad<jupyter_output><empty_output><jupyter_text>f(x,y) = x2 + y2<jupyter_code>x = nd.array([[1,0], [0,1]])
y = nd.array([[1,1], [1,1]])
x.attach_grad()
y.attach_grad()
f = lambda x,y : x**2 + y**2
with autograd.record():
    z = f(x,y)
z.backward()
print(x.grad * y.grad)<jupyter_output>[[4. 0.]
 [0. 4.]]
<NDArray 2x2 @cpu(0)>
{'fraction_non_alphanumeric': 0.20497803806734993, 'fraction_numerical': 0.03953147877013177, 'mean_word_length': 5.452830188679245, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '153747', 'license': 'Apache-2.0', 'n_tokens_mistral': 334, 'n_tokens_neox': 330, 'n_words': 63, 'path': 'autograd.ipynb', 'repo_name': 'tuyendq/lthwmxnet', 'size': '683'}