小编Maë*_* LC的帖子

AttributeError:'Tensor'对象没有属性'_keras_history'

我查找了所有"'Tensor'对象没有属性***"但似乎没有任何与Keras有关(除了TensorFlow:AttributeError:'Tensor'对象没有属性'log10'没有帮助)...

我正在制作一种GAN(Generative Adversarial Networks).在这里你可以找到结构.

Layer (type)                     Output Shape          Param #         Connected to                     
_____________________________________________________________________________
input_1 (InputLayer)             (None, 30, 91)        0                                            
_____________________________________________________________________________
model_1 (Model)                  (None, 30, 1)         12558           input_1[0][0]                    
_____________________________________________________________________________
model_2 (Model)                  (None, 30, 91)        99889           input_1[0][0]                    
                                                                       model_1[1][0]                    
_____________________________________________________________________________
model_3 (Model)                  (None, 1)             456637          model_2[1][0]                    
_____________________________________________________________________________
Run Code Online (Sandbox Code Playgroud)

我预先训练了model_2和model_3.事情是我预先训练了model_2,列表由0和1组成,但是model_1返回了接近的值.所以我考虑使用以下代码舍入model1_output:model1_out上的K.round().

import keras.backend as K
[...]
def make_gan(GAN_in, model1, model2, model3):
    model1_out = model1(GAN_in)
    model2_out = model2([GAN_in, K.round(model1_out)])
    GAN_out = model3(model2_out)
    GAN = Model(GAN_in, GAN_out)
    GAN.compile(loss=loss, optimizer=model1.optimizer, metrics=['binary_accuracy'])
    return GAN
[...]
Run Code Online (Sandbox Code Playgroud)

我有以下错误:

AttributeError:'Tensor'对象没有属性'_keras_history'

完全追溯: …

python attributeerror keras

14
推荐指数
3
解决办法
2万
查看次数

连接层的ValueError(Keras功能API)

经过一些搜索,我仍然无法找到解决方案.我是Keras的新手,如果有解决方案我会道歉并且我实际上不明白它与我的问题有什么关系.

我正在使用Keras 2/Functional API制作一个小型RNN,我无法使Concatenate Layer工作.

这是我的结构:

inputSentence = Input(shape=(30, 91))
sentenceMatrix = LSTM(91, return_sequences=True, input_shape=(30, 91))(inputSentence)

inputDeletion = Input(shape=(30, 1))
deletionMatrix = (LSTM(30, return_sequences=True, input_shape=(30, 1)))(inputDeletion)

fusion = Concatenate([sentenceMatrix, deletionMatrix])
fusion = Dense(122, activation='relu')(fusion)
fusion = Dense(102, activation='relu')(fusion)
fusion = Dense(91, activation='sigmoid')(fusion)

F = Model(inputs=[inputSentence, inputDeletion], outputs=fusion)
Run Code Online (Sandbox Code Playgroud)

这是错误:

ValueError: Unexpectedly found an instance of type `<class 'keras.layers.merge.Concatenate'>`. Expected a symbolic tensor instance.
Run Code Online (Sandbox Code Playgroud)

完整的历史,如果它有助于更​​多:

Using TensorFlow backend.
    str(inputs) + '. All inputs to the layer '
ValueError: Layer dense_1 was called …
Run Code Online (Sandbox Code Playgroud)

python concatenation neural-network keras valueerror

8
推荐指数
1
解决办法
7064
查看次数