Keras LSTM和致密层 [英] Keras lstm and dense layer

查看:223
本文介绍了Keras LSTM和致密层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

致密层如何改变LSTM层的输出?从上一层的50个成形输出中,我如何从用于预测的密集层中得到大小为1的输出? 可以说我有这个基本模型:

How is dense layer changing the output coming from LSTM layer? How come that from 50 shaped output from previous layer i get output of size 1 from dense layer that is used for prediction? Lets say i have this basic model:

model = Sequential()
model.add(LSTM(50,input_shape=(60,1)))
model.add(Dense(1, activation="softmax"))

密集层是不是从前一层取值,然后分配50个输入中每个输入的概率(使用softmax函数),然后将其作为输出?

Is the Dense layer taking the values coming from previous layer and assigning the probablity(using softmax function) of each of the 50 inputs and then taking it out as an output?

推荐答案

否,Dense层不能那样工作,输入具有50维,输出将具有等于神经元数量的尺寸,一个在这种情况下.输出是输入加上偏差的加权线性组合.

No, Dense layers do not work like that, the input has 50-dimensions, and the output will have dimensions equal to the number of neurons, one in this case. The output is a weighted linear combination of the input plus a bias.

请注意,使用softmax激活时,将其与一个神经元层一起使用是没有意义的,因为softmax已标准化,所以唯一可能的输出将是常数1.0.现在可能就是您想要的.

Note that with the softmax activation, it makes no sense to use it with a one neuron layer, as the softmax is normalized, the only possible output will be constant 1.0. That's probably now what you want.

这篇关于Keras LSTM和致密层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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