Skip to content

API Reference

benchmark(model_path, target='tic62124646', sector=13, exptime=120, author='SPOC', backends=None)

Benchmark inference speed across available backends on a standard light curve.

Parameters:

Name Type Description Default
model_path str

Path to a .keras model file.

required
target str

TIC identifier (default: 'tic62124646').

'tic62124646'
sector int

TESS sector to download (default: 13).

13
exptime int

Cadence in seconds (default: 120).

120
author str

Lightkurve author (default: 'SPOC').

'SPOC'
backends list[str] | None

Specific backends to test; if None, use available ones.

None

check_backend(print_summary=True)

Report available Keras backends and device acceleration.

Returns a dict with keys: current, candidates, and per-backend info.

require_backend(backend=None)

Validate that the selected Keras backend is installed and usable.

Parameters:

Name Type Description Default
backend str | None

Backend to require ('jax' or 'torch'). If None, uses the active backend from KERAS_BACKEND or keras.backend.backend().

None

Raises:

Type Description
RuntimeError

If the required backend is not installed or has no available devices.

swap_backend(backend, accelerator=None, restart=False)

Prepare environment for a different Keras backend and accelerator.

Note: Keras backend is selected at import time. If keras is already imported in this process, you must restart the interpreter for the change to take effect. Setting restart=True will perform an in-place re-exec.

Parameters:

Name Type Description Default
backend str

One of 'jax' or 'torch'.

required
accelerator str | None

Optional accelerator hint: 'cpu', 'cuda'/'gpu', or 'mps' (Apple Metal).

None
restart bool

If True and keras is already imported, re-exec the current process.

False