Skip to content

Instantly share code, notes, and snippets.

View jiayihu's full-sized avatar
:octocat:
Nyaning in O(1)

Jiayi Hu jiayihu

:octocat:
Nyaning in O(1)
View GitHub Profile
@jiayihu
jiayihu / utils.ts
Last active September 24, 2020 09:22
Cross-project utilities
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
export type ValueOf<T> = T[keyof T];
export function assertNever(_: never): never {
throw new Error('Unreachable code');
}
export function debounce<F extends (...params: Array<any>) => void>(fn: F, delay: number): F {
let timer: NodeJS.Timeout;
@jiayihu
jiayihu / machine.js
Created October 23, 2019 09:07
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jiayihu
jiayihu / ML.md
Created June 16, 2020 09:07
Welcome file

Machine Learning

Supervised learning

  • Inductive bias
  • Spazio delle ipotesi $H$ con ipotesi $h \in H$
  • version space, spazio delle ipotesi tra gli estremi di quelle consistenti
  • Ad esempio spazio delle curve polinomiali, con obiettivo minimizzare: $min_{w} 1/n \sum_{i=1}^n (y_i - wx_i)^2$
  • Training/empirical error vs ideal error
@jiayihu
jiayihu / machine.js
Created November 15, 2020 16:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
#![allow(non_snake_case)]
fn init_array<const M: usize, const N: usize>(
A: &mut [[f32; N]; M],
r: &mut [f32; M],
p: &mut [f32; N],
) {
for i in 0..N {
p[i] = (i % N) as f32 / N as f32;
}