Created
September 4, 2022 19:35
-
-
Save bwasti/9817171e47c75c2d8b484ed69abdae11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as sm from '@shumai/shumai' | |
class EvalTuner { | |
constructor() { | |
this.best_delta = 1 | |
this.best_time = Infinity | |
this.last_i = 0 | |
} | |
calculate_better_delta(time_spent) { | |
} | |
step(t, i) { | |
const delta = i - this.last_i | |
if (delta >= this.best_delta) { | |
// see how well we did this time | |
t.eval() | |
const time_spent = (performance.now() - this.last_time) / delta | |
console.log("delta", this.best_delta, "took", time_spent, "ms per increment") | |
this.calculate_better_delta(time_spent) | |
this.last_i = i | |
this.last_time = performance.now() | |
} | |
} | |
} | |
const eval_tuner = new EvalTuner() | |
const b = sm.randn([1]) | |
let t = sm.randn([1]) | |
for (let i = 0; i < 1000; ++i) { | |
t = t.add(b) | |
eval_tuner.step(t, i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment