<jupyter_start><jupyter_text>$Perceptron-1$$y = \sum{x_i*w_i}+b$<jupyter_code>x = torch.randn(1,10)
w = torch.randn(1,10,requires_grad = True)
o = torch.sigmoid(torch.matmul(x,w.t()))
o.shape
loss = F.mse_loss(o,torch.ones(1,1))
loss.shape
loss.backward()
w.grad<jupyter_output><empty_output><jupyter_text>$Perceptron-2$$y = \sum{x_i*w_i}+b$<jupyter_code>x = torch.randn(1,10)
w = torch.randn(2,10,requires_grad = True)
o = torch.sigmoid(x @ w.t())
o.shape
loss = F.mse_loss(torch.ones(1,2),o)
loss
loss.backward()
w.grad<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20326678765880218, 'fraction_numerical': 0.032667876588021776, 'mean_word_length': 7.492307692307692, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '552904', 'license': 'MIT', 'n_tokens_mistral': 282, 'n_tokens_neox': 274, 'n_words': 28, 'path': 'Pytorch/Pytorch_learn_by_dragen1860/lesson17-感知机的梯度推导.ipynb', 'repo_name': 'tsuirak/skills', 'size': '551'}