Registry / ai-ml / kt-legacy

kt-legacy

JSON →
library1.0.5pypypiunverified

The `kt-legacy` library provides backward-compatible import names for Keras Tuner. It allows users to import Keras Tuner components using the `kerastuner` namespace, which was the original import path, instead of the current `keras_tuner` namespace. This is particularly useful for migrating or maintaining compatibility with older codebases that expect the `kerastuner` module.

pip install kt-legacy
INSTALL
IMPORT
SIG · KT-LEGACY
K
kt-legacy
ai-mlpythonv1.0.5
Install
5.1s avg
Import
Disk
84MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
2/4 runs
✓ 5.1s
py 3.11
2/4 runs
✓ 4.88s
py 3.12
2/4 runs
✓ 4.48s
py 3.13
2/4 runs
✓ 4.68s
py 3.9
2/4 runs
✓ 6.18s
84MB installed
● package 84MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

kerastuner
import keras_tuner as kerastuner
import kerastuner

This quickstart demonstrates how to import and initialize a Keras Tuner `RandomSearch` tuner using the `kerastuner` legacy import provided by the `kt-legacy` package. It defines a simple hypermodel and initializes the tuner, ready for a hyperparameter search.

import keras import kerastuner as kt def build_model(hp): model = keras.Sequential([ keras.layers.Flatten(input_shape=(28, 28)), keras.layers.Dense( units=hp.Int('units', min_value=32, max_value=512, step=32), activation='relu' ), keras.layers.Dense(10, activation='softmax') ]) model.compile( optimizer=keras.optimizers.Adam(learning_rate=hp.Choice('learning_rate', values=[1e-2, 1e-3, 1e-4])), loss='sparse_categorical_crossentropy', metrics=['accuracy'] ) return model # Example of using a tuner with the legacy import tuner = kt.RandomSearch( hypermodel=build_model, objective='val_accuracy', max_trials=2, # For quick demonstration executions_per_trial=1, directory='my_dir', project_name='intro_to_kt_legacy' ) # Note: To run search, you would typically need training data, e.g., # (img_train, label_train), (img_test, label_test) = keras.datasets.fashion_mnist.load_data() # img_train = img_train.astype('float32') / 255.0 # label_train = label_train[:100] # Subset for quick example # img_train = img_train[:100] # tuner.search(img_train, label_train, epochs=2, validation_split=0.2) print("Keras Tuner (legacy import) initialized successfully.") # print(tuner.get_best_hyperparameters()[0].values)
Debug
Known issues
deprecatedThe `kerastuner` import path is deprecated in favor of `keras_tuner` within the main Keras Tuner library. While `kt-legacy` provides compatibility, new projects should use `keras_tuner` directly to align with current best practices and avoid potential future breakage.
fix
For new code, replace `import kerastuner` with `import keras_tuner` and update references accordingly. For existing code, ensure `kt-legacy` is installed alongside `keras-tuner`.
affects: < 2.0.0 of `keras-tuner` for direct `kerastuner` usage, `kt-legacy` is designed for all versions.
gotcha`kt-legacy` only provides the legacy import alias. It does not include the Keras Tuner functionality itself. `keras-tuner` must be installed separately for the aliased imports to function.
fix
Ensure both `keras-tuner` and `kt-legacy` are installed: `pip install keras-tuner kt-legacy`.
affects: All versions
Upgrade
Version history
1.0.5latest on PyPI · released Apr 12, 2023
Audit
Dependencies
keras-tunerrequired`kt-legacy` provides backward-compatible import names for the `keras-tuner` library. It will not function correctly without `keras-tuner` installed.
Agent activity
12 hits · last 30 days
node
12
Resources
kt-legacy — pip install kt-legacy · libregistry