Skip to main content

alt-model-checkpoint

An adapter callback for Keras ModelCheckpoint that allows checkpointing an alternate model (often submodel of a multi-GPU model).

Installation

pip install alt-model-checkpoint

Usage

You must provide your own Keras or Tensorflow installation. See Pipfile for preferred versions.

If using the Keras bundled in Tensorflow:

from alt_model_checkpoint.tensorflow import AltModelCheckpoint

If using Keras standalone:

from alt_model_checkpoint.keras import AltModelCheckpoint

Common usage involving multi-GPU models built with Keras multi_gpu_model():

from alt_model_checkpoint.keras import AltModelCheckpoint
from keras.models import Model
from keras.utils import multi_gpu_model

def compile_model(m):
    """Implement with your model compile logic; both base and GPU models should be compiled identically"""
    m.compile(...)

base_model = Model(...)
gpu_model = multi_gpu_model(base_model)
compile_model(base_model)
compile_model(gpu_model)

gpu_model.fit(..., callbacks=[
    AltModelCheckpoint('save/path/for/model.hdf5', base_model)
])

Constructor args

filepath

Model save file path; see underlying ModelCheckpoint docs for details.

alternate_model

Keras model to save instead of the default. This is used especially when training multi-gpu models built with Keras multi_gpu_model(). In that case, you would pass the original "template model" to be saved each checkpoint.

inherit_optimizer

If TRUE (default), saves the optimizer of the base model (e.g. a multi-gpu model) with the alternate model. This is necessary if you want to be able to resume training on a saved alternate model. If FALSE, the alternate model's optimizer will be saved as-is.

*args, **kwargs

These are passed as-is to the underlying ModelCheckpoint constructor.

Dev environment setup

  1. Install pipenv.
  2. Run make test (runs make test-build automatically to ensure deps)

Release files for alt-model-checkpoint 2.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alt-model-checkpoint 2.0.3
File Size Uploaded
alt-model-checkpoint-2.0.3.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for alt-model-checkpoint 2.0.3
File Interpreter ABI Platform
alt_model_checkpoint-2.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / alt-model-checkpoint-2.0.3.tar.gz

Download URL alt-model-checkpoint-2.0.3.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6001eae3329d2d90da02413eca04725deab54a834f2539288ee3f10832ea10a7
BLAKE2b-256 checksum
How to use checksums
0f14f956f4f4e3bc750bc0615570e341a884c34bafcd260273d69b3d2b140396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

Release files / alt_model_checkpoint-2.0.3-py3-none-any.whl

Download URL alt_model_checkpoint-2.0.3-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e71d8395de254f3a02fdff5a1ec2ad5bc2cfcbc7fcffd17e36e23740cbb92e98
BLAKE2b-256 checksum
How to use checksums
0a00c0091a1b99d97374ada680d741f96ec23ba8d49310f3f7d21a379182afe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

Release history Release notifications | RSS feed

This release

2.0.3 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.13.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page