gpt4 book ai didi

python - 在 Keras 中合并,类型错误 : module object not callable?

转载 作者:太空宇宙 更新时间:2023-11-04 04:20:32 24 4
gpt4 key购买 nike

我正在尝试连接所有输入,但出于某种原因,我总是收到该错误:类型错误:模块对象不可调用,你能帮我解决这个问题吗?我尝试用 Keras.layers.concatenate 替换合并,但没有成功。

def stack_latent_layers(n):
#Stack n bidi LSTMs
return lambda x: stack(x, [lambda : Bidirectional(LSTM(hidden_units,
return_sequences = True))] * n )

def predict_classes():
#Predict to the number of classes
#Named arguments are passed to the keras function
return lambda x: stack(x,
[lambda : TimeDistributed(Dense(output_dim = num_of_classes(),
activation = "softmax"))] +
[lambda : TimeDistributed(Dense(hidden_units,
activation='relu'))] * 3)

word_embedding_layer = emb.get_keras_embedding(
trainable = True,
input_length = sent_maxlen, name='word_embedding_layer')


pos_embedding_layer = Embedding(output_dim = pos_tag_embedding_size,
input_dim = len(SPACY_POS_TAGS),
input_length = sent_maxlen,
name='pos_embedding_layer')

latent_layers = stack_latent_layers(num_of_latent_layers)

dropout = Dropout(0.1)

predict_layer = predict_classes()


## --------> 8] Prepare input features, and indicate how to embed them
inputs_and_embeddings = [(Input(shape = (sent_maxlen,),
dtype="int32",
name = "word_inputs"),
word_embedding_layer),
(Input(shape = (sent_maxlen,),
dtype="int32",
name = "predicate_inputs"),
word_embedding_layer),
(Input(shape = (sent_maxlen,),
dtype="int32",
name = "postags_inputs"),
pos_embedding_layer),
]
print('inputs_and_embeddings',inputs_and_embeddings)

## --------> 9] Concat all inputs and run on deep network
output = predict_layer(dropout(latent_layers(merge([embed(inp)
for inp, embed in inputs_and_embeddings],
mode = "concat",
concat_axis = -1
))))

最佳答案

用 keras.layers.concatenate 替换合并

关于python - 在 Keras 中合并,类型错误 : module object not callable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54561175/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com