我用以下代码构建了一个模型:
model_input = Input(shape=(449, 8, 1))
x = Conv2D(64, (25, 20),padding='same', input_shape=( 449, 8, 1),activation="relu")(model_input)
x = BatchNormalization()(x)
x = Conv2D(128, (25, 20),padding='same', input_shape=( 449, 8, 1),activation="relu")(x)
x = BatchNormalization()(x)
x = Flatten()(x)
x = Dense(8, activation='relu')(x)
x = BatchNormalization()(x)
x = Dense(8, activation='softmax')(x)
model = Model(input=model_input ,output=x)
在导入以下Keras库时,它可以完美运行:
from keras.layers import Conv2D, Input, BatchNormalization, Flatten, Dense
from keras.models import Model
from keras.optimizers import Adam
但是当我尝试在tensorflow中使用内置的Keras API并构建相同的模型时:
from tensorflow.keras.layers import Conv2D, Input, BatchNormalization, Flatten, Dense
from tensorflow.keras.models import Model
from tensorflow.keras.optimizers import Adam
错误已合并:
TypeError:_init_subclassed_network()获得了意外的关键字参数“输入”
我正在使用tensorflow-gpu 1.13.1。