Skip to content

Commit

Permalink
[system-a] rename sqrt to squareRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed May 21, 2024
1 parent c5d8c03 commit fd3de4b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# system-a

[system-a] rename `sqrt` to `squareRoot`
[the-book] rename `sqrt` to `squareRoot`
[system-a] `gradientDescentRms`

# the-book
Expand Down
4 changes: 2 additions & 2 deletions src/system-a/gradient-descent/gradientDescentRms.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tensorZeros, type Tensor } from "../tensor/index.js"
import { add, div, mul, sqrt, square, sub } from "../toys/index.js"
import { add, div, mul, square, squareRoot, sub } from "../toys/index.js"
import type { Representation } from "./Representation.js"
import { gradientDescent } from "./gradientDescent.js"
import { smooth } from "./smooth.js"
Expand All @@ -19,7 +19,7 @@ export function gradientDescentRms(options: {
// NOTE Add `stabilizer` to avoid `div` by zero.
const adaptiveLearningRate = div(
options.learningRate,
add(stabilizer, sqrt(r)),
add(stabilizer, squareRoot(r)),
)
return [sub(p, mul(adaptiveLearningRate, g)), r]
},
Expand Down
4 changes: 2 additions & 2 deletions src/system-a/toys/toys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const exptScalar = prim2(
(ra, rb, z) => [rb * ra ** (rb - 1) * z, ra ** rb * Math.log(ra) * z],
)

export const sqrtScalar = prim1(
export const squareRootScalar = prim1(
(x) => Math.sqrt(x),
(ra, z) => (1 / 2) * ra ** (-1 / 2) * z,
)
Expand All @@ -51,7 +51,7 @@ export const mul = extend2(mulScalar)
export const div = extend2(divScalar)
export const log = extend1(logScalar)
export const expt = extend2(exptScalar)
export const sqrt = extend1(sqrtScalar)
export const squareRoot = extend1(squareRootScalar)
export const square = extend1(squareScalar)

export const lt = comparator((x, y) => x < y)
Expand Down

0 comments on commit fd3de4b

Please sign in to comment.