Welcome to keras_gtar’s documentation!

keras_gtar is an in-development library for saving and restoring keras models inside libgetar files. By using a trajectory-based format, we can save multiple versions of a model’s weights.

Installation

Install keras_gtar from source on github:

pip install git+https://github.com/klarh/keras_gtar.git#egg=keras_gtar

API Documentation

class keras_gtar.Trajectory(filename, mode='r', group=None)[source]

Interface to save and load models from a GTAR trajectory

Parameters:
  • filename – File to save or load from
  • mode – File open mode: ‘r’ (read-only), ‘w’ (overwrite), or ‘a’ (append)
  • group – GTAR group prefix to use to organize multiple sub-trajectories within the same GTAR file, if given
get_weights(frame=-1)[source]

Returns a list of weight arrays for a model stored at the given frame index

Parameters:frame – integer index of the step to load. Can be negative to count from the end.
load(frame=-1, extra_classes={})[source]

Loads a model stored at the given frame index

Parameters:
  • frame – integer index of the step to load. Can be negative to count from the end.
  • extra_classes – Dictionary of additional (name: Class) values to use when initializing model.
save(model, frame=None, only_weights=False)[source]

Save a model description and/or current state

Parameters:
  • frame – Frame index (string) to save as. If not given, do not save weights.
  • only_weights – If True, only save the current model weights, not the model architecture.
save_model(model)[source]

Save (only) the current model architecture.

Parameters:model – Keras Model object to save
save_weights(model, frame)[source]

Save (only) the current model weights.

Parameters:
  • model – Keras Model object containing weights to save
  • frame – Frame index (string) to save as
keras_gtar.GTARLogger

Indices and tables