context class to allow setting the current context. Example usage with brew: - with UseOptimizer(optim): brew.func - with UseOptimizer({'WEIGHT': weight_optim}): brew.func - with UseOptimizer({'DEFAULT': optim, 'BIAS': bias_optim, 'WEIGHT': weight_optim}): brew.func - with UseOptimizer(optim1): brew.func with UseOptimizer(optim2): brew.func Example useage with layer: optimizers = {'optim1': optim1, 'optim2': optim2} with Optimizers(optimizers): optim = OptimizerContext.current().get_optimizer('optim1') layer(optim=optim)
Definition at line 31 of file optimizer_context.py.