-
-
Save Amplify4177/e08674d591a6f6a979304cfe58298e3b to your computer and use it in GitHub Desktop.
ESP32 ML - Model Class Implementation
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
| 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