Skip to content

Commit

Permalink
gradientDescent -- inline revise -- for log
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Jun 4, 2024
1 parent 6bf6de1 commit b028e35
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
`gradientDescent` -- inline `revise` for log

修复鸢尾花模型的问题。

- https://github.com/xieyuheng/learner/issues/2
Expand Down
9 changes: 7 additions & 2 deletions src/system-a/gradient-descent/gradientDescent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { zip } from "../../utils/zip.js"
import { assertTensorArray, type Tensor } from "../tensor/index.js"
import type { Representation } from "./Representation.js"
import { gradient } from "./index.js"
import { revise } from "./revise.js"

export type GradientDescentFn = (
objective: (...ps: Array<Tensor>) => Tensor,
Expand All @@ -23,7 +22,13 @@ export function gradientDescent<R>(
return zip(rs, gs).map(([r, g]) => representation.update(r, g))
}

const rs = revise(step, options.revs, ps.map(representation.inflate))
let revs = options.revs
let rs = ps.map(representation.inflate)
while (revs > 0) {
rs = step(rs)
revs--
}

return rs.map(representation.deflate)
}
}
11 changes: 0 additions & 11 deletions src/system-a/gradient-descent/revise.test.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/system-a/gradient-descent/revise.ts

This file was deleted.

0 comments on commit b028e35

Please sign in to comment.