属性错误:'Tensor'对象没有属性'_keras_history'。

8
Aux_input = Input(shape=(wrd_temp.shape[1],1), dtype='float32')#shape (,200)
Main_input = Input(shape=(wrdvec.shape[1],),dtype='float32')#shape(,367)

X = Bidirectional(LSTM(20,return_sequences=True))(Aux_input)
X = Dropout(0.2)(X)
X = Bidirectional(LSTM(28,return_sequences=True))(X)
X = Dropout(0.2)(X)
X = Bidirectional(LSTM(28,return_sequences=False))(X)
Aux_Output = Dense(Opt_train.shape[1], activation= 'softmax' )(X)#total 22 classes

x = keras.layers.concatenate([Main_input,Aux_Output],axis=1)

x = tf.reshape(x,[1,389,1])#here 389 is the shape of the new input i.e.(
Main_input+Aux_Output)

x = Bidirectional(LSTM(20,return_sequences=True))(x)
x = Dropout(0.2)(x)
x = Bidirectional(LSTM(28,return_sequences=True))(x)
x = Dropout(0.2)(x)
x = Bidirectional(LSTM(28,return_sequences=False))(x)
Main_Output = Dense(Opt_train.shape[1], activation= 'softmax' )(x)

model = Model(inputs=[Aux_input,Main_input], outputs=    [Aux_Output,Main_Output])

在声明模型的行中出现错误,即 model = Model(),这里发生了属性错误。另外,如果我的实现中有任何其他错误,请在评论部分注意并通知我。


2
尝试使用x = Reshape((1,389,1))(x) - Marcin Możejko
这个会起作用吗,因为x是张量。 - karan patel
形状必须是3阶,但对于“bidirectional_4/Tile”(op:“Tile”),它的等级为2,其输入形状为[?,1,1],[2]。@Marcin Mozejko,我在您建议后进行修改后出现了这个错误,您能帮忙吗? - karan patel
你能打印出 model.summary() 吗? - Marcin Możejko
@daniel 13岁时,我已经实现了它。 - karan patel
显示剩余7条评论
1个回答

5
问题在于每个 tf 操作都必须由以下之一进行封装:
  1. 使用 keras.backend 函数,
  2. Lambda 层,
  3. 具有相同行为的指定 keras 函数。
当您使用 tf 操作时,您将获得一个不带有 history 字段的 tf 张量对象。当您使用 keras 函数时,您将获得 keras.tensor

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接