Skip to content

Commit

Permalink
MNT update import for keras
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Oct 21, 2021
1 parent 58f4a11 commit 7e94390
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/miscellaneous.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ calling ``fit_generator`` method to train the model. To illustrate, we will
define a logistic regression model::

>>> import keras
>>> y = keras.utils.to_categorical(y, 3)
>>> y = keras.utils.np_utils.to_categorical(y, 3)
>>> model = keras.Sequential()
>>> model.add(keras.layers.Dense(y.shape[1], input_dim=X.shape[1],
... activation='softmax'))
Expand Down
8 changes: 4 additions & 4 deletions imblearn/keras/_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def import_from_keras():
try:
import keras # noqa

return (keras.utils.data_utils.Sequence,), True
return (keras.utils.Sequence,), True
except ImportError:
return tuple(), False

Expand All @@ -33,10 +33,10 @@ def import_from_tensforflow():
ParentClassTensorflow, has_keras_tf = import_from_tensforflow()
has_keras = has_keras_k or has_keras_tf
if has_keras:
if has_keras_tf:
ParentClass = ParentClassTensorflow
else:
if has_keras_k:
ParentClass = ParentClassKeras
else:
ParentClass = ParentClassTensorflow
else:
ParentClass = (object,)
return ParentClass, has_keras
Expand Down
2 changes: 1 addition & 1 deletion imblearn/keras/tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
keras = pytest.importorskip("keras")
from keras.models import Sequential # noqa: E402
from keras.layers import Dense # noqa: E402
from keras.utils import to_categorical # noqa: E402
from keras.utils.np_utils import to_categorical # noqa: E402

from imblearn.datasets import make_imbalance # noqa: E402
from imblearn.under_sampling import ClusterCentroids # noqa: E402
Expand Down

0 comments on commit 7e94390

Please sign in to comment.