Skip to content

Instantly share code, notes, and snippets.

@Amplify4177
Last active November 9, 2023 14:01
Show Gist options
  • Select an option

  • Save Amplify4177/e08674d591a6f6a979304cfe58298e3b to your computer and use it in GitHub Desktop.

Select an option

Save Amplify4177/e08674d591a6f6a979304cfe58298e3b to your computer and use it in GitHub Desktop.
ESP32 ML - Model Class Implementation
class Model:
def __init__(self, layers, inp_norm_mean=0, inp_norm_sd=1):
self.layers = layers
### Subtract the mean divide by SD
self.inp_norm = lambda inp: normInput(inp, 1/inp_norm_sd, -inp_norm_mean)
def __call__(self, inp):
return self.forward(inp)
def __getitem__(self, i):
return self.layers[i]
def forward(self, inp):
out = self.inp_norm(inp)
for l in self.layers:
out = l(out)
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment