SShortSingh.
Back to feed

How PyTorch's autograd computes every gradient automatically

0
·3 views

Backpropagation done by hand works for a tiny network but does not scale to models with millions of weights. PyTorch instead records each operation of the forward pass as a graph node as the code runs, with every result keeping a link to the function that produced it. Calling L.backward() then walks this graph in reverse, applying each node's local derivative to the gradient passed down from above. Gradients accumulate in buckets attached to the weights that requested them, and when a value feeds several paths the contributions are summed. For the worked example, the resulting gradients match the values obtained by hand.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Why None Is Not Enough: Sentinel Values for PATCH Updates in Python

A recent Hacker News discussion on sentinel values in Python prompted the author to recall a production bug from an update function that used None to mean both "not provided" and "clear the value." The problem surfaces clearly in PATCH APIs, where a field can be absent, explicitly null, or set to a value, and a plain None default cannot distinguish the first two cases. The article reviews the common object()-based sentinel and points out its drawbacks: an unhelpful repr, unreliable copying and pickling, and poor type-checker support. It then proposes an Enum-based sentinel that keeps a readable repr, survives deepcopy and pickle as a singleton, and lets type checkers narrow the type correctly.

0
ProgrammingDEV Community ·

Student Team Builds Offline AI Tool to Log Developer Decisions at Overnight Hackathon

A student developer describes their first overnight hackathon at Hacktoberfest Hack Day, held on the NST campus in Sonipat. Their four-person team built IssueFlowP6, an offline command-line tool that extracts architectural decisions from developer chat logs using a local Qwen 2.5 model via Ollama. The tool is designed to avoid hallucinations and data leaks associated with cloud-based models by verifying extracted quotes with a deterministic engine. The author recounts a Git mishap during the sprint that was resolved by isolating their work on a separate branch. The team finished a working pipeline before the deadline and submitted the write-up to a Hacktoberfest blog challenge.

0
ProgrammingDEV Community ·

Sipmap team builds DejaView to recover rejected ideas and reasons from old open source discussions

At a Hacktoberfest Hack Day in Sonipat, a four-person team took on a problem asking for a system that reads past discussions and recovers the decisions made in them. They were inspired by the recurring loss of reasoning in open source projects, citing Python's rejected 'x as y' proposal as an example where the rationale lived only in a heated thread. Their tool, DejaView, reads a Python PEP discussion and returns the rejected ideas, why each failed, and the post where it was said. To work within the twelve-hour limit, the members divided the work by area and agreed on folder ownership and interfaces up front. Early on, they hit an API quirk where a thread request returned success with no posts, because the service uses separate global and human-visible post IDs.

0
ProgrammingDEV Community ·

Terraphim Skills 1.0.0 launches as a ChatGPT plugin for searching engineering workflows

Terraphim Skills 1.0.0 is now available as a ChatGPT plugin, bringing its engineering-skills catalogue into conversations. The plugin offers five read-only tools that let users check their connected account, browse and search skills, inspect skill details, and retrieve content their account is entitled to access. The catalogue centres on practical engineering and knowledge-work practices, including a V-model path running from research and design through to verification and validation. Premium skill bodies are not accessible through ChatGPT, and access otherwise follows the connected account's entitlements. The developers invite users to install the plugin, connect their account, and share feedback on skills and future workflows.