Skip to content

Commit 91e7fcc

Browse files
Fix bug with tensorflow 2.15, remove dependencies constraints
1 parent 077349e commit 91e7fcc

File tree

9 files changed

+23
-15
lines changed

9 files changed

+23
-15
lines changed

.github/workflows/run-test-coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v2
19-
- name: Set up Python 3.8
19+
- name: Set up Python 3.11
2020
uses: actions/setup-python@v2
2121
with:
22-
python-version: '3.8'
22+
python-version: '3.11'
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip

.github/workflows/run-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
build:
1414
strategy:
1515
matrix:
16-
python-version: [3.6, 3.7, 3.8, 3.9]
16+
python-version: [3.11] #[3.6, 3.7, 3.8, 3.9]
1717
os: [ubuntu-latest, windows-latest, macos-latest]
1818
exclude:
1919
- os: windows-latest

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ docs_build/
2121
docs/html/
2222
docs/doctrees/
2323
adapt/datasets.py
24-
datasets/
24+
datasets/
25+
debug.ipynb

adapt/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
from sklearn.metrics.pairwise import KERNEL_PARAMS
1414
from sklearn.exceptions import NotFittedError
1515
from tensorflow.keras import Model
16-
from tensorflow.keras.wrappers.scikit_learn import KerasClassifier, KerasRegressor
16+
try:
17+
from tensorflow.keras.wrappers.scikit_learn import KerasClassifier, KerasRegressor
18+
except:
19+
from scikeras.wrappers import KerasClassifier, KerasRegressor
1720
try:
1821
from tensorflow.keras.optimizers.legacy import RMSprop
1922
except:
@@ -1623,7 +1626,7 @@ def _get_length_dataset(self, dataset, domain="src"):
16231626

16241627

16251628
def _check_for_batch(self, dataset):
1626-
if dataset.__class__.__name__ == "BatchDataset":
1629+
if "BatchDataset" in dataset.__class__.__name__:
16271630
return True
16281631
if hasattr(dataset, "_input_dataset"):
16291632
return self._check_for_batch(dataset._input_dataset)

adapt/instance_based/_iwc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def fit_weights(self, Xs, Xt, warm_start=False, **kwargs):
170170
else:
171171
y_pred = self.classifier_.predict(Xs).ravel()
172172

173-
self.weights_ = 1. / (y_pred + EPS) - 1.
173+
self.weights_ = 1. / np.clip(y_pred, EPS, 1.) - 1.
174174

175175
return self.weights_
176176

adapt/instance_based/_tradaboost.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def fit(self, X, y, Xt=None, yt=None,
218218
self : returns an instance of self
219219
"""
220220
set_random_seed(self.random_state)
221-
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
221+
# tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
222222

223223
Xs, ys = check_arrays(X, y, accept_sparse=True)
224224
Xt, yt = self._get_target_data(Xt, yt)
@@ -757,9 +757,9 @@ class TwoStageTrAdaBoostR2(TrAdaBoostR2):
757757
--------
758758
>>> from sklearn.linear_model import Ridge
759759
>>> from adapt.utils import make_regression_da
760-
>>> from adapt.instance_based import TrAdaBoostR2
760+
>>> from adapt.instance_based import TwoStageTrAdaBoostR2
761761
>>> Xs, ys, Xt, yt = make_regression_da()
762-
>>> model = TrAdaBoostR2(Ridge(), n_estimators=10, Xt=Xt[:10], yt=yt[:10], random_state=0)
762+
>>> model = TwoStageTrAdaBoostR2(Ridge(), n_estimators=10, Xt=Xt[:10], yt=yt[:10], random_state=0)
763763
>>> model.fit(Xs, ys)
764764
Iteration 0 - Cross-validation score: 0.2956 (0.0905)
765765
Iteration 1 - Cross-validation score: 0.2956 (0.0905)
@@ -814,7 +814,7 @@ def fit(self, X, y, Xt=None, yt=None,
814814
sample_weight_tgt=None,
815815
**fit_params):
816816
set_random_seed(self.random_state)
817-
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
817+
# tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
818818

819819
Xs, ys = check_arrays(X, y, accept_sparse=True)
820820
Xt, yt = self._get_target_data(Xt, yt)

adapt/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
from sklearn.utils import check_array
1212
from sklearn.linear_model import LinearRegression, LogisticRegression
1313
from sklearn.base import BaseEstimator, ClassifierMixin, RegressorMixin, clone
14-
from tensorflow.keras.wrappers.scikit_learn import KerasClassifier, KerasRegressor
14+
try:
15+
from tensorflow.keras.wrappers.scikit_learn import KerasClassifier, KerasRegressor
16+
except:
17+
from scikeras.wrappers import KerasClassifier, KerasRegressor
1518
import tensorflow as tf
1619
import tensorflow.keras.backend as K
1720
from tensorflow.keras import Sequential, Model

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
numpy
22
scipy
3-
tensorflow < 2.12
3+
tensorflow
44
scikit-learn
5-
cvxopt <= 1.3.0
5+
cvxopt
6+
scikeras

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
author_email='[email protected]',
1414
license='BSD-2',
1515
packages=find_packages(exclude=["tests"]),
16-
install_requires=["numpy>=1.16", "scipy>=1.0", "tensorflow<2.12", "scikit-learn>=0.2", "cvxopt<=1.3.0"],
16+
install_requires=["numpy", "scipy", "tensorflow", "scikit-learn", "cvxopt", "scikeras"],
1717
zip_safe=False,
1818
long_description=long_description,
1919
long_description_content_type='text/markdown'

0 commit comments

Comments
 (0)