lstm输入为:shape= (samples,time_steps,input_dim)
samples :样本数量
time_steps:时间步长
input_dim:每一个时间布上的纬度
样本数为N,步长为1,数据集(A,B,C,D)四个属性,D为标签,输入:shape=(N,1,4)
具体数据:[A(t-1),B(t-1),C(t-1),D(t-1)]表示一个数据样本,样本标签[D(t)]
样本数为N,步长为2,数据集(A,B,C,D)四个属性,D为标签,输入:shape=(N,2,4)
具体数据:[A(t-2),B(t-2),C(t-2),D(t-2),A(t-1),B(t-1),C(t-1),D(t-1)]仍表示一个数据样本,样本标签D(t)
lstm输出:output_dim:
return_sequence = True,返回(samples,time_steps,output_dim) 3D张量
return_sequence = False,返回(samples,output_dim) 2D张量
例如:shape=(N,2,8),同时output_dim = 32, return_sequence = True时返回(N,2,32)
return_sequence = False时,返回为(N,32)表示输出序列的最后一个输出
# as first layer in a sequential model:
model = Sequential()
model.add(Dense(32, input_shape=(16,)))
# now the model will take as input arrays of shape (*, 16)
# and output arrays of shape (*, 32)
# 现在模型将采用形状的输入数组(*,16),和形状的输出数组(*,32)
# after the first layer, you don't need to specify
# the size of the input anymore:在第一层之后,您不再需要指定输入的大小:
model.add(Dense(32)) # 定义32个节点
model.predict 和model.evaluate的区别
版权声明:本文为W1510109901原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。