AttributeError: 'NoneType' object has no attribute '_inbound_nodes' in Keras

后端 未结 1 889
[愿得一人]
[愿得一人] 2021-01-23 16:39

I want to define my own Lstm model as follows:

from keras import backend as K
from keras.callbacks import ModelCheckpoint
from keras.layers.core import Dense, Ac         


        
1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 17:17

    You should use keras.layers.Lambda to wrap K.* operations as a layer instead of K.* function directly.

    # change
    avg_pool = K.mean(rnn_outputs, axis = 1)
    max_pool = K.max(rnn_outputs, axis = 1)
    # to
    avg_pool = Lambda(lambda x:K.mean(x,axis=1))(rnn_outputs)
    max_pool = Lambda(lambda x:K.max(x,axis=1))(rnn_outputs)
    

    0 讨论(0)
提交回复
热议问题