liveBook · Manning

Computation graph

As explained in Build AI Drug Discovery Pipelines

A computational graph is a directed graph whose nodes represent computational operations or values and whose edges represent their dependencies.

A computation graph represents a mathematical expression as a directed graph: nodes hold operations or variables, and edges show how data flows between them. section 8.2.1

In machine learning, inputs and trainable parameters pass through operations to produce a prediction. Comparing that prediction with a target produces a loss, which connects the graph to training. section 8.2.1 section 8.2

A computation graph makes several training mechanics explicit:

  • Operation nodes can represent multiplication, addition, sigmoid activation, or loss calculation. section 8.2.1
  • Setting requires_grad=True on parameters allows PyTorch to track the quantities needed for gradient computation. section 8.2.1
  • Calling loss.backward() traverses the graph backward and computes how weights and bias contributed to the loss. section 8.2.1

Logistic regression in PyTorch

For an input tensor x, compute z = sum(x * w) + b, apply sigmoid(z), compare the prediction with a target using binary cross-entropy, and call loss.backward() to obtain gradients for w and b. The same graph pattern scales from a single input to molecular activity models using 2,048-bit Morgan fingerprints and predicted EGFR pIC50 values. section 8.2

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Defines graph structure and demonstrates logistic-regression forward and backward passes, while deferring deeper automatic-differentiation internals.
Examples
Uses logistic regression, a PyTorch gradient listing, neural-network diagrams, and EGFR activity prediction from Morgan fingerprints.
What it assumes
Assumes basic mathematical expressions and machine-learning terminology while introducing graph nodes, data flow, loss, and gradients.
What you can do after
Apply PyTorch computational graphs to inspect predictions, losses, and parameter gradients during model training.
How it connects
Connects logistic regression, neural networks, automatic differentiation, backpropagation, gradients, loss, and PyTorch.

Also explained in

Compare how 8 books explain computation graph →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.