Skip to content

Releases

Infinite Training 2.2.0

Choose a tag to compare

@vyncint vyncint released this 28 Jul 05:11
a069822

Adds a PyTorch backend. Backward compatible: the Keras API is unchanged and no existing checkpoint needs converting.

TorchTrainer

PyTorch has no fit, so you hand over the training step and the trainer calls it once per round:

from infinite_training import TorchTrainer, Target

def step() -> dict[str, float]:
    optimizer.zero_grad()
    loss = loss_fn(model(x), y)
    loss.backward()
    optimizer.step()
    return {"loss": loss.item()}

trainer = TorchTrainer(model=model, target=Target("loss", True, 1e-4), timeout=60)
trainer.train(step)
predictions, best_loss = trainer.predict_best(x)

Everything around the step — the Target, the round loop, the timeout, Ctrl+C handling, checkpointing and resume — is shared with the Keras trainer. One round is one call to your step function, so you choose the granularity at which the target and timeout are checked.

There is no compile(): the shadow copy holding the best weights is built in the constructor, so inference works straight away.

Install

pip install "infinite-training[torch]"

Checkpoints are NumPy state dicts rather than torch.save archives, so a checkpoint written on a GPU resumes on a CPU with no device map, and stays readable without PyTorch installed.

Backends are now imported lazily

import infinite_training no longer imports TensorFlow, and referencing TorchTrainer never imports it either — one framework installed is enough. Asking for a trainer whose framework is missing raises an ImportError that names the extra:

TorchTrainer requires torch, which is not installed.
Install it with: pip install 'infinite-training[torch]'

TensorFlow remains a hard dependency for the whole 2.x line, so no existing pip install infinite-training breaks. It moves to the [tensorflow] extra in 3.0.0. A torch-only user can opt out today with pip install --no-deps infinite-training plus numpy torch.

Heads up if you install both frameworks

The default PyTorch wheel bundles CUDA libraries that clash with the ones TensorFlow loads, and importing both into one process can segfault the interpreter. This is not specific to this package — import tensorflow; import torch is enough to trigger it on Linux. If you need both, install the CPU build:

pip install torch --index-url https://download.pytorch.org/whl/cpu

The lazy imports mean you will not hit this while using a single backend.

Also in this release

  • The loop, target and timeout bookkeeping, value history and checkpoint paths moved into an internal _base module shared by both backends. No public name changed.
  • examples/mnist_torch.py, the PyTorch counterpart of the Keras MNIST example.
  • 93 tests, 38 of them new, plus a CI job that installs each framework on its own and runs the suite to keep the lazy-import claim honest.

Full changelog: https://github.com/vyncint/infinite-training/blob/main/CHANGELOG.md

Infinite Training 2.1.0

Choose a tag to compare

@vyncint vyncint released this 27 Jul 22:22
103f17f

Backward compatible with 2.0.0: existing code keeps working and warns where an
API has been renamed.

Fixed

  • Target(target_value=0) is now honoured. The default was selected with
    target_value or <bound>, so a falsy 0/0.0 was replaced by an unreachable
    bound and the session could never stop on that target.
  • last_value no longer raises AttributeError when read before training, or
    after an interrupt during the first round. It is derived from the persisted
    value history, so it also survives a restart.
  • Target() is no longer used as a default argument value, which meant every
    trainer built without an explicit target shared one mutable instance.
  • Calling train() or an inference method before compile() now raises a clear
    RuntimeError instead of AttributeError: 'InfiniteTrainer' object has no attribute 'best_model'.
  • A target naming a metric that is absent from the training history now raises a
    RuntimeError listing the available keys, instead of a bare KeyError. When
    the missing key starts with val_, the message points at validation_data.
  • Checkpoint parent directories are created automatically; previously a path
    such as runs/exp1/best.npy failed unless the directory already existed.
  • Restored checkpoint values are converted back to Python floats and plain
    weight lists rather than being left as zero-dimensional object arrays.
  • KeyboardInterrupt is logged instead of silently swallowed.
  • requires-python corrected from >=3.9 to >=3.10. TensorFlow has required
    3.10 or newer since 2.16, so the old floor advertised an uninstallable
    combination.

Added

  • InfiniteTrainer, the new name for InfinityTraining.
  • rounds_completed property.
  • save() as a public method for checkpointing on demand.
  • Target.is_improvement(), Target.is_reached() and
    Target.worst_possible_value, so the comparison rules live with the target.
  • __version__ and __all__ exports.
  • A CI workflow running lint, tests on Python 3.10-3.12, and a packaging check
    on every push and pull request. Previously tests ran only when a release was
    published.
  • The publish workflow verifies that the release tag matches the packaged
    version.
  • CONTRIBUTING.md, CHANGELOG.md, and a rewritten README.md with an API
    reference, a resume guide and a security note.
  • Test suite covering targets, stop conditions, persistence and resume,
    error handling, and the deprecation shims (55 tests, up from 3).

Changed

  • The package is split into target.py, trainer.py and _storage.py. Public
    imports are unchanged: from infinite_training import InfiniteTrainer, Target.
  • Type hints use float rather than np.double for scalar values.
  • Progress and stop reasons are reported through the logging module.
  • run.py moved to examples/mnist.py and no longer ships inside the wheel.
  • Packaging declares its packages explicitly, so tests is no longer picked up
    by auto-discovery.

Removed

  • The unused polars runtime dependency.

Deprecated

The following still work and will be removed in 3.0.0:

Deprecated Replacement
InfinityTraining InfiniteTrainer
optimize_weight best_weights
last_weight last_weights
optimize_value best_value
list_value value_history
optimize_model best_model
predict_optimize() predict_best()
optimize_weight_path= best_weights_path=
last_weight_path= last_weights_path=
optimize_value_path= best_value_path=
list_value_path= value_history_path=

Full changelog: https://github.com/vyncint/infinite-training/blob/main/CHANGELOG.md
Compare: v2.0.0...v2.1.0

Infinite Training 2.0.0

Choose a tag to compare

@vyncint vyncint released this 03 Apr 02:54

Full Changelog: v1.0.0...v2.0.0

Infinite Training 1.0.0

Choose a tag to compare

@vyncint vyncint released this 15 Oct 11:00

Fix wrong url

Infinite Training 0.0.1

Choose a tag to compare

@vyncint vyncint released this 15 Oct 10:55
abdff9a

Init python package