Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Upgrade tensorflow to 2.16.1 and keras to 3.4.0 #1385

Merged

Commits on Jun 26, 2024

  1. Feat: Upgrade tensorflow to 2.16.1 and keras to 3.4.0

    To accommodate the upgrade, next changes to the code were made:
    
    * Since `keras 3.*` now clones the input `regressor` that is provided to the `BaseEstimator` into a `regressor_` attribute, and ONLY updates the `regressor_` one after fitting, metadata extraction in `gordo.builder.build_model.ModelBuilder` was changed to seek the `regressor_` in the `steps`.
    * Accessing `keras.optimizers` has changed in `keras 3.*` to having to use the `keras.optimizers.get` method and providing a `class_name` and `config` to deserialize. Relevant for lstm and feedforward autoencoders.
    * Model config now requires for `tensorflow.keras.models.Sequential` to define `input_shape` in its layers, otherwise model is not properly built after compiling and prior to fitting. Relevant for `KerasRawModelRegressor`.
    
    `KerasBaseEstimator` underwent the most changes.
    
    * We now need to run the `__init__` of the KerasRegressor with the expected `kwargs` for proper initialisation of the object, but the `kwargs` will always take precedence for `fit`, `predict` and `compile`, so they are mostly for making `keras` happy.
    * Saving model for pickling was changed ƒrom `h5` format, which is now considered legacy to `keras` native zip format, and the file is now stored to a temporary file and read into a buffer instead of using the `h5py` library, since `save_model` and `load_model` now exclusively expect an actual file instead of an io buffer.
    * Current implementation of model preparation for fit depends on the `__call__` method, which is no longer used in `keras 3.*`, and was changed to `_prepare_model` to replicate the same behaviour right before we call our own `fit` since it requires the `X` and `Y` to be present to set the `n_features` and `n_features_out`.
    * `History` is no longer returned from calling `fit` and must be extracted from under `model.history`.
    * Manually stored history now resides in `self._history` instead of `self.history` to avoid attribute name clash.
    
    Adjustments to tests were made:
    
    * `input_shape` now resides under `input.shape` in `model.layers`.
    * `optimizer_kwargs.lr` is now `optimizer_kwargs.learning_rate`
    RollerKnobster committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    225fb2f View commit details
    Browse the repository at this point in the history
  2. Fix: formatting

    RollerKnobster committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    6259b05 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c53efbf View commit details
    Browse the repository at this point in the history
  4. Fix: minor refactoring

    RollerKnobster committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    29a715f View commit details
    Browse the repository at this point in the history
  5. Fix: minor refactoring

    RollerKnobster committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    9680e35 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d6ab506 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    5733d98 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    7ecaed7 View commit details
    Browse the repository at this point in the history