用非符号张量keras的输入调用的层 [英] Layer called with an input that isn't a symbolic tensor keras

查看:47
本文介绍了用非符号张量keras的输入调用的层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将一层的输出传递到两个不同的层,然后将它们重新结合在一起.但是,我被这个错误阻止了,该错误告诉我输入的不是符号张量.

I'm trying to pass the output of one layer into two different layers and then join them back together. However, I'm being stopped by this error which is telling me that my input isn't a symbolic tensor.

Received type: <class 'keras.layers.recurrent.LSTM'>. All inputs to the layers should be tensors.

但是,我相信我会非常关注文档: https://keras.io/入门/functional-api-guide/#multi-input-and-multi-output-models

However, I believe I'm following the documentation quite closely: https://keras.io/getting-started/functional-api-guide/#multi-input-and-multi-output-models

不能完全确定为什么这是错误的吗?

and am not entirely sure why this is wrong?

net_input = Input(shape=(maxlen, len(chars)), name='net_input')
lstm_out = LSTM(128, input_shape=(maxlen, len(chars)))

book_out = Dense(len(books), activation='softmax', name='book_output')(lstm_out)
char_out = Dense(len(chars-4), activation='softmax', name='char_output')(lstm_out)

x = keras.layers.concatenate([book_out, char_out])
net_output = Dense(len(chars)+len(books), activation='sigmoid', name='net_output')

model = Model(inputs=[net_input], outputs=[net_output])

谢谢

推荐答案

看起来您实际上并没有为LSTM层提供输入.您指定了复发神经元的数量和输入的 shape ,但未提供输入.试试:

It looks like you're not actually giving an input to your LSTM layer. You specify the number of recurrent neurons and the shape of the input, but do not provide an input. Try:

lstm_out = LSTM(128, input_shape=(maxlen, len(chars)))(net_input)

这篇关于用非符号张量keras的输入调用的层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆