Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:_init_subclassed_network()获取了意外的关键字参数';输入';使用TensorFlow Keras时_Python_Tensorflow_Keras - Fatal编程技术网

Python TypeError:_init_subclassed_network()获取了意外的关键字参数';输入';使用TensorFlow Keras时

Python TypeError:_init_subclassed_network()获取了意外的关键字参数';输入';使用TensorFlow Keras时,python,tensorflow,keras,Python,Tensorflow,Keras,我按照以下代码构建了一个模型: 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),acti

我按照以下代码构建了一个模型:

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:\u init\u subclass\u network()得到一个意外的关键字参数“input”


顺便说一句,我正在使用tensorflow gpu 1.13.1。

我在Keras API上看到,参数是
输入
输出


请重新检查,

我在Keras API上看到,参数是
输入
输出


请重新检查,

我在Keras API上看到,参数是
输入
输出
。请重新检查,它解决了我的问题!!但奇怪的是,我使用
input
output
作为参数,当库来自纯keras API时,它仍然有效,但当库来自tensorflow时不起作用。你可以继续把你的评论作为答案,这样我就可以把它标记为正确,并给你我在keras API上看到的声誉,参数是
输入
输出
。请重新检查,它解决了我的问题!!但奇怪的是,我使用
输入
输出
作为参数,当从纯keras API中创建库时,它仍然有效,但当从tensorflow创建库时不起作用。您可以继续将您的注释作为答案,这样我就可以将其标记为正确,并为您赢得声誉