From e6334f4e5663f9c3673d82d3d0d58077c2df35f8 Mon Sep 17 00:00:00 2001 From: Fabiana <30911746+fabclmnt@users.noreply.github.com> Date: Fri, 3 May 2024 19:06:38 +0100 Subject: [PATCH] feat: bump tensorflow and tensorflow probability versions (#336) * feat: bump tensorflow and tensorflow probability versions * chore: update github flows python version * chore: update github flows python version for pull request --- .github/workflows/prerelease.yml | 4 ++-- .github/workflows/pull_request.yml | 4 ++-- requirements.txt | 8 ++++---- src/ydata_synthetic/synthesizers/saving_keras.py | 14 ++++++++------ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 579460bb..d341929f 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -19,10 +19,10 @@ jobs: id: version run: echo ::set-output name=value::${GITHUB_REF#refs/*/} - - name: Setup Python 3.8 + - name: Setup Python 3.10 uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.10' - name: Install dependencies run: | diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 5377a9d6..2026915e 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -17,10 +17,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Python 3.8 + - name: Setup Python 3.10 uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.10' - name: Cache pip id: cache diff --git a/requirements.txt b/requirements.txt index 8ed4264b..e7edeeae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ -requests>=2.30, <2.31 +requests>=2.28, <2.31 pandas<3 numpy<2 scikit-learn<2 matplotlib<4 -tensorflow==2.12.0 -tensorflow-probability==0.19.0 +tensorflow==2.15.* +tensorflow-probability[tf] easydict==1.10 pmlb==1.0.* tqdm<5.0 -typeguard==4.0.* +typeguard==4.2.* pytest==7.4.* diff --git a/src/ydata_synthetic/synthesizers/saving_keras.py b/src/ydata_synthetic/synthesizers/saving_keras.py index fb6c3c67..faf98bcf 100644 --- a/src/ydata_synthetic/synthesizers/saving_keras.py +++ b/src/ydata_synthetic/synthesizers/saving_keras.py @@ -1,19 +1,21 @@ +import tensorflow.python.keras as tf_keras +from keras import __version__ +tf_keras.__version__ = __version__ + from tensorflow.keras import Model -from tensorflow.python.keras.layers import deserialize, serialize -from tensorflow.python.keras.saving import saving_utils def unpack(model, training_config, weights): - restored_model = deserialize(model) + restored_model = tf_keras.layers.deserialize(model) if training_config is not None: - restored_model.compile(**saving_utils.compile_args_from_training_config(training_config)) + restored_model.compile(**tf_keras.saving.saving_utils.compile_args_from_training_config(training_config)) restored_model.set_weights(weights) return restored_model def make_keras_picklable(): def __reduce__(self): - model_metadata = saving_utils.model_metadata(self) + model_metadata = tf_keras.saving.saving_utils.model_metadata(self) training_config = model_metadata.get("training_config", None) - model = serialize(self) + model = tf_keras.layers.serialize(self) weights = self.get_weights() return (unpack, (model, training_config, weights))