Improving training and inference for embedded machine learning