Hierarchical configuration framework
Project description
confugue
is a hierarchical configuration framework for Python. It provides a wrapper class for nested configuration dictionaries (usually loaded from YAML files), which can be used to configure complicated object hierarchies in a recursive fashion.
As an example, here is a simplified code snippet from a machine learning project which uses confugue
:
@configurable
class Model:
def __init__(self, vocabulary, use_sampling=False):
self.embeddings = self._cfg['embedding_layer'].configure(EmbeddingLayer,
input_size=len(vocabulary))
self.decoder = self._cfg['decoder'].configure(RNNDecoder,
vocabulary=vocabulary,
embedding_layer=self.embeddings)
@configurable
class RNNDecoder:
def __init__(self, vocabulary, embedding_layer):
self.cell = self._cfg['cell'].configure(tf.keras.layers.GRUCell,
units=100,
dtype=tf.float32)
self.output_projection = self._cfg['output_projection'].configure(
tf.layers.Dense,
units=len(vocabulary),
use_bias=False)
The model could then be configured using the following config file, overriding the values specified in the code and filling in the ones that are missing.
embedding_layer:
output_size: 300
decoder:
cell:
class: !!python/name:tensorflow.keras.layers.LSTMCell
units: 1024
use_sampling: True
Installation & Documentation
A full documentation can be found here.
The package is available from PyPI and can be installed with pip install confugue
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.