Я пытаюсь импортировать keras, используя jupyternotebook, но получаю сообщение об ошибке.
в целом, используя tenorflow.keras.XX вместо keras.XX, чтобы решить проблему, но это не относится к keras.layers,Есть ли другой способ решить проблему? ниже приведен код, который я написал
import tensorflow as tf
import tensorflow.keras
from tensorflow.keras import backend as k
from tensorflow.keras.models import Model, load_model, save_model
from tensorflow.keras.layers import Input,Dropout,BatchNormalization,Activation,Add
from keras.layers.core import Lambda
from keras.layers.convolutional import Conv2D, Conv2DTranspose
from keras.layers.pooling import MaxPooling2D
from tensorflow.keras.layers.merge import concatenate
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint, ReduceLROnPlateau
from tensorflow.keras import backend as K
from tensorflow.keras import optimizers
, а ниже приведена ошибка, которую я получаю
from tensorflow.keras.preprocessing.image import array_to_img, img_to_array, load_img#,save_img
import time
t_start = time.time()
<ipython-input-51-e901beac4908> in <module>
4 from tensorflow.keras.models import Model, load_model, save_model
5 from tensorflow.keras.layers import Input,Dropout,BatchNormalization,Activation,Add
----> 6 from keras.layers.core import Lambda
7 from keras.layers.convolutional import Conv2D, Conv2DTranspose
8 from keras.layers.pooling import MaxPooling2D
/usr/local/lib/python3.5/dist-packages/keras/__init__.py in <module>
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
/usr/local/lib/python3.5/dist-packages/keras/utils/__init__.py in <module>
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7 from . import losses_utils
8 from . import metrics_utils
/usr/local/lib/python3.5/dist-packages/keras/utils/conv_utils.py in <module>
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
/usr/local/lib/python3.5/dist-packages/keras/backend/__init__.py in <module>
----> 1 from .load_backend import epsilon
2 from .load_backend import set_epsilon
3 from .load_backend import floatx
4 from .load_backend import set_floatx
5 from .load_backend import cast_to_floatx
/usr/local/lib/python3.5/dist-packages/keras/backend/load_backend.py in <module>
88 elif _BACKEND == 'tensorflow':
89 sys.stderr.write('Using TensorFlow backend.\n')
---> 90 from .tensorflow_backend import *
91 else:
92 # Try and load external backend.
/usr/local/lib/python3.5/dist-packages/keras/backend/tensorflow_backend.py in <module>
52
53 # Private TF Keras utils
---> 54 get_graph = tf_keras_backend.get_graph
55 # learning_phase_scope = tf_keras_backend.learning_phase_scope # TODO
56 name_scope = tf.name_scope
AttributeError: module 'tensorflow.python.keras.backend' has no attribute 'get_graph'