Skip to content

Commit 7e94390

Browse files
committed
MNT update import for keras
1 parent 58f4a11 commit 7e94390

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Diff for: doc/miscellaneous.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ calling ``fit_generator`` method to train the model. To illustrate, we will
136136
define a logistic regression model::
137137

138138
>>> import keras
139-
>>> y = keras.utils.to_categorical(y, 3)
139+
>>> y = keras.utils.np_utils.to_categorical(y, 3)
140140
>>> model = keras.Sequential()
141141
>>> model.add(keras.layers.Dense(y.shape[1], input_dim=X.shape[1],
142142
... activation='softmax'))

Diff for: imblearn/keras/_generator.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def import_from_keras():
1717
try:
1818
import keras # noqa
1919

20-
return (keras.utils.data_utils.Sequence,), True
20+
return (keras.utils.Sequence,), True
2121
except ImportError:
2222
return tuple(), False
2323

@@ -33,10 +33,10 @@ def import_from_tensforflow():
3333
ParentClassTensorflow, has_keras_tf = import_from_tensforflow()
3434
has_keras = has_keras_k or has_keras_tf
3535
if has_keras:
36-
if has_keras_tf:
37-
ParentClass = ParentClassTensorflow
38-
else:
36+
if has_keras_k:
3937
ParentClass = ParentClassKeras
38+
else:
39+
ParentClass = ParentClassTensorflow
4040
else:
4141
ParentClass = (object,)
4242
return ParentClass, has_keras

Diff for: imblearn/keras/tests/test_generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
keras = pytest.importorskip("keras")
99
from keras.models import Sequential # noqa: E402
1010
from keras.layers import Dense # noqa: E402
11-
from keras.utils import to_categorical # noqa: E402
11+
from keras.utils.np_utils import to_categorical # noqa: E402
1212

1313
from imblearn.datasets import make_imbalance # noqa: E402
1414
from imblearn.under_sampling import ClusterCentroids # noqa: E402

0 commit comments

Comments
 (0)