ReadTheDocs

Flowws Modules for Machine Learning Experiments with Keras

flowws-keras-experimental is a set of flowws modules to train machine learning models using tensorflow and keras. It contains basic modules to perform common tasks such as loading data and specifying model architectures.

Installation

Install flowws-keras-experimental from PyPI:

pip install flowws-keras-experimental

Alternatively, install from source:

pip install git+https://github.com/klarh/flowws-keras-experimental.git#egg=flowws-keras-experimental

API Documentation

Browse more detailed documentation online or build the sphinx documentation from source:

git clone https://github.com/klarh/flowws-keras-experimental
cd flowws-keras-experimental/doc
pip install -r requirements.txt
make html

Base Modules

class flowws_keras_experimental.InitializeTF(**kwargs)[source]

Initialize tensorflow, enabling memory growth for GPUs.

Parameters:
  • jit – If True, enable JIT compilation

  • gpu – If False, disable GPUs

  • memory_growth – If True, enable gradual memory growth

  • memory_fraction – If given, limit the GPU memory to the given fraction of available memory

class flowws_keras_experimental.Classifier(**kwargs)[source]

Specify a simple classifier output.

Parameters:

activation – None

class flowws_keras_experimental.MLP(**kwargs)[source]

Specify a multilayer perceptron model.

Parameters:
  • hidden_widths – Number of nodes for each hidden layer

  • activation – None

  • batch_norm – Apply batch normalization before all hidden layers

  • output_batch_norm – Apply batch normalization after each hidden layer

  • flatten – None

  • dropout – Apply a dropout layer with the given dropout rate after each hidden layer

class flowws_keras_experimental.PermanentDropout(**kwargs)[source]

Make dropout layers used by later modules use test-time dropout.

class flowws_keras_experimental.Tensorboard(**kwargs)[source]

Specify a tensorboard dump callback.

Parameters:
  • histogram_period – Frequency to dump histogram data

  • write_graph – Write the computational graph

  • profile_batch – Batch index to profile (0 to disable)

class flowws_keras_experimental.Train(**kwargs)[source]

Build a model and perform some number of training steps.

Training will proceed for the model and dataset that have been specified in previous stages.

Parameters:
  • optimizer – optimizer to use

  • optimizer_kwargs – Keyword arguments to pass to optimizer

  • epochs – Max number of epochs

  • batch_size – Batch size

  • validation_split – None

  • early_stopping – None

  • early_stopping_best – If True, restore the best weights at the end of early stopping

  • reduce_lr – None

  • reduce_lr_factor – Factor to scale learning rate with reduce_lr enabled

  • dump_period – None

  • hash_size – If given, use a hash of the workflow description for the dump filename

  • seed – None

  • summarize – If True, print the model summary before training

  • recompile – If True, always compile the model in this stage

  • verbose – If True, print the training progress

  • clean_batch_multiple – If True, make the training data a clean multiple of the batch size

  • rebuild_model – If True, always rebuild the model when one already exists

  • generator_train_steps – Number of steps to use as an epoch for training from a generator

  • generator_val_steps – Number of steps to use as an epoch for evaluation from a generator

  • disable_tqdm – If True, don’t use tqdm to display a progress bar

  • use_multiprocessing – If True, use multiprocessing with generators

  • accumulate_gradients – Number of batches over which to accumulate gradients before applying

  • catch_keyboard_interrupt – If True, catch keyboard interrupts and continue to the next stage

  • monitor_quantity – Quantity to monitor for reduce_lr and early_stopping

  • shuffle_labels – If True, shuffle labels for training

  • checkpoint_dir – If given, save and restore model checkpoints at the given location

  • checkpoint_duration – Time duration for model checkpointing, if enabled

  • catch_sigterm – If True, catch sigterm events and continue to the next stage

  • terminate_on_nan – If True, terminate training on nan loss

  • gtar_log_period – Number of epochs to buffer for logging quantities via GTAR

  • gtar_log_modifiers – Filename modifiers for live logging of quantities via GTAR

class flowws_keras_experimental.Save(**kwargs)[source]

Save the architecture and weights of a model using keras_gtar.

Parameters:
  • save_model – None

  • hash_size – If given, use a hash of the workflow description for the dump filename

  • group – If given, set the GTAR group ID to save with

  • file_modifiers – List of additional filename modifiers to use