moco
moco takes machine learning models (or any "learned" function) and optimizes them
for computational efficiency. moco consists of a suite of algorithms that optimize models
for computational efficiency with no accuracy loss.
moco analyzes data to find early-exit strategies to exploit:
moco analyzes the internal parameters (weights and biases) to find equivalent loss-less representations for models.
moco also analyzes the interaction of the parameters with the data/activations to find equivalent loss-less representations to represent models.
moco is a pip-installable Python package that offers:
prune_neurons(model: MLPClassifier, data: np.ndarray) -> MLPClassifiercondense_neurons(model: MLPClassifier, data: np.ndarray) -> Tuple[MLPClassifier, LogisticRegression]Notes:
model is uploaded as a .joblib file.model.activation must be "relu".condense_neurons returns two models whose summed output matches
the original model.
prune_neurons returns one model whose output matches the original model.
class RoutedModel:
base: torch.nn.Module
conditional: torch.nn.Module
router: torch.nn.Module
yes_path: torch.nn.Module
no_path: torch.nn.Module
compute_rule(model: torch.nn.Sequential, layer_name: str, data: torch.utils.data.Dataset) -> RoutedModel
Notes:
yes_path is a simple constant function.get_layers(model: torch.nn.Sequential) -> List[str]profile_layers(model: torch.nn.Sequential, data: torch.utils.data.Dataset) -> List[Tuple[str, float]]