Skip to content

Commit

Permalink
Update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-innocenti committed Nov 22, 2024
1 parent 6633836 commit 58e57f3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ result = jpc.make_pc_step(
output=y,
input=x
)

# updated model and optimiser
model = result["model"]
optim, opt_state = result["optim"], result["opt_state"]
```
Under the hood, `jpc.make_pc_step`
1. integrates the inference (activity) dynamics using a [Diffrax](https://github.com/patrick-kidger/diffrax) ODE solver, and
Expand All @@ -92,24 +96,23 @@ Under the hood, `jpc.make_pc_step`
## 🚀 Advanced usage
More advanced users can access any of the functionality used by `jpc.make_pc_step`.
A custom PC training step would look like the following

A custom PC training step would look like the following
```py
import jpc

# 1. initialise activities with a feedforward pass
activities = jpc.init_activities_with_ffwd(model=model, input=x)

# 2. run the inference dynamics to equilibrium
equilibrated_activities = jpc.solve_pc_inference(
# 2. run inference to equilibrium
equilibrated_activities = jpc.solve_inference(
params=(model, None),
activities=activities,
output=y,
input=x
)

# 3. update parameters with PC
step_result = jpc.update_params(
# 3. update parameters at the activities' solution with PC
result = jpc.update_params(
params=(model, None),
activities=equilibrated_activities,
optim=optim,
Expand Down

0 comments on commit 58e57f3

Please sign in to comment.