<jupyter_start><jupyter_text>This is an object that knows how to compute function(forward) or derivative(backward)<jupyter_code>print('Gradient function for z = ', z.grad_fn)
print('Gradient function for loss = ', loss.grad_fn)<jupyter_output>Gradient function for z =  <AddBackward0 object at 0x7f7f7c032700>
Gradient function for loss =  <BinaryCrossEntropyWithLogitsBackward object at 0x7f7f7c032550><jupyter_text>`loss.backward()`: computes the derivatives of our loss function WRT parameters`.grad`: retreives the values<jupyter_code>loss.backward()
print(w.grad)
print(b.grad)<jupyter_output>tensor([[0.0057, 0.2723, 0.0204],
        [0.0057, 0.2723, 0.0204],
        [0.0057, 0.2723, 0.0204],
        [0.0057, 0.2723, 0.0204],
        [0.0057, 0.2723, 0.0204]])
tensor([0.0057, 0.2723, 0.0204])<jupyter_text>Surrounding code with `with torch.nograd():` block stops tracking computations. This is used when we only want to do forward computations<jupyter_code>z = torch.matmul(x,w)+b
print(z.requires_grad)

with torch.no_grad():
    z = x@w+b
print(z.requires_grad)
z = x@w+b
z_det = z.detach()
print(z_det.requires_grad)<jupyter_output>False
{'fraction_non_alphanumeric': 0.13141862489120976, 'fraction_numerical': 0.09660574412532637, 'mean_word_length': 5.388888888888889, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '67423', 'license': 'MIT', 'n_tokens_mistral': 511, 'n_tokens_neox': 437, 'n_words': 98, 'path': 'Pytorch/Tutorial_Autograd.ipynb', 'repo_name': 'tylertaewook/RLpractice', 'size': '1149'}