LSTM模型

The article is with respect to LSTM model apply

Introduction

As our company’s project requires the use of LSTM models for frame-to-frame movement classification. So this article is about how to use LSTM models.


一、Picture comprehension process

在这里插入图片描述

二、Code Usage

'''
	 input_size shape is (batchsize,sequence_length,features).hidden_size is h(t)  eigenvector, the larger this hidden_size parameter is, the more features the next sequence outputs, the more computationally intensive it is, but it may alse be overfitted. batchfirst is true,input_size is (batchsize,sequence_length,features),but if batchfirst is False, input_size shape is (sequence_length, batch_size,input_size). 
bidirectional is true, this is because LSTM become Bidirectional LSTM, This is become better.
'''
self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True, bidirectional=True)
'''
	LSTM层数*双向,批次大小,隐藏层维度
'''
h0 = torch.zeros(self.lstm.num_layers * 2, b, self.lstm.hidden_size).to(x.device)
c0 = torch.zeros(self.lstm.num_layers * 2, b, self.lstm.hidden_size).to(x.device)
out, _ = self.lstm(x, (h0, c0))

总结

会用就行

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
LSTM(Long Short-Term Memory)是一种循环神经网络(RNN)的变体,它在处理序列数据时具有较强的记忆能力。LSTM模型可以用于预测CPI(Consumer Price Index,消费者价格指数)。 LSTM模型通过学习历史CPI数据的模式和趋势,可以预测未来的CPI值。下面是使用LSTM模型预测CPI的一般步骤: 1. 数据准备:收集历史CPI数据,并将其分为训练集和测试集。通常,可以使用前一段时间的CPI数据作为训练集,然后使用后续时间段的CPI数据进行测试。 2. 数据预处理:对CPI数据进行标准化或归一化处理,以便在训练过程中更好地处理数据。 3. 构建LSTM模型:使用Python中的深度学习框架(如TensorFlow或PyTorch)构建LSTM模型LSTM模型由多个LSTM层组成,每个层都有一定数量的隐藏单元。 4. 模型训练:使用训练集对LSTM模型进行训练。在训练过程中,模型将学习历史CPI数据的模式和趋势。 5. 模型评估:使用测试集评估训练好的LSTM模型的性能。可以使用各种指标(如均方根误差、平均绝对误差等)来评估模型的预测准确度。 6. 模型预测:使用已训练的LSTM模型对未来的CPI进行预测。将历史CPI数据输入到模型中,模型将输出预测的CPI值。 需要注意的是,LSTM模型的预测结果可能受到多种因素的影响,如历史CPI数据的质量、模型的参数设置等。因此,在使用LSTM模型进行CPI预测时,需要谨慎选择和处理数据,以及调整模型参数,以提高预测准确度。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值