当前位置: 首页 > wzjs >正文

今日国际新闻最新新闻seo比较好的公司

今日国际新闻最新新闻,seo比较好的公司,php网站开发的成功经历,郑州网站建设贴吧前言: 最近在大模型预测,简单了解了lag-llama开源项目,网上也有很多讲解原理的,这里就将如何快速上手使用说一下,只懂得一点点皮毛,有错误的地方欢迎大佬指出。 简单介绍: Lag-Llama 是一个开…

前言:

最近在大模型预测,简单了解了lag-llama开源项目,网上也有很多讲解原理的,这里就将如何快速上手使用说一下,只懂得一点点皮毛,有错误的地方欢迎大佬指出。

简单介绍:

Lag-Llama 是一个开源的时间序列预测模型,基于 Transformer 架构设计,专注于利用 滞后特征(Lagged Features) 捕捉时间序列的长期依赖关系。其核心思想是将传统时间序列分析中的滞后算子(Lags)与现代深度学习结合,实现对复杂时序模式的高效建模。

GitHup地址:GitHub - time-series-foundation-models/lag-llama: Lag-Llama: Towards Foundation Models for Probabilistic Time Series Forecasting

相关技术原理:...(搜一下很多文章讲的都非常好)

实现模型预测:

1.下载模型文件

从 HuggingFace下载,如果网络原因访问不了,建议从魔搭社区下载(lag-Llama · 模型库)

2.准备数据集

参考文档:pandas.DataFrame based dataset - GluonTS documentation

以我测试数据举例:

3.完整代码:(需要替换模型文件地址和数据集地址)

from itertools import islicefrom matplotlib import pyplot as plt
import matplotlib.dates as mdatesimport torch
from gluonts.evaluation import make_evaluation_predictions, Evaluator
from gluonts.dataset.repository.datasets import get_datasetfrom gluonts.dataset.pandas import PandasDataset
import pandas as pdfrom lag_llama.gluon.estimator import LagLlamaEstimatordef get_lag_llama_predictions(dataset, prediction_length, device, num_samples, context_length=32, use_rope_scaling=False):# 模型文件地址ckpt = torch.load("/models/lag-Llama/lag-llama.ckpt", map_location=device, weights_only=False)  # Uses GPU since in this Colab we use a GPU.estimator_args = ckpt["hyper_parameters"]["model_kwargs"]rope_scaling_arguments = {"type": "linear","factor": max(1.0, (context_length + prediction_length) / estimator_args["context_length"]),}estimator = LagLlamaEstimator(# 模型文件地址ckpt_path="/models/lag-Llama/lag-llama.ckpt",prediction_length=prediction_length,context_length=context_length,# Lag-Llama was trained with a context length of 32, but can work with any context length# estimator argsinput_size=estimator_args["input_size"],n_layer=estimator_args["n_layer"],n_embd_per_head=estimator_args["n_embd_per_head"],n_head=estimator_args["n_head"],scaling=estimator_args["scaling"],time_feat=estimator_args["time_feat"],rope_scaling=rope_scaling_arguments if use_rope_scaling else None,batch_size=1,num_parallel_samples=100,device=device,)lightning_module = estimator.create_lightning_module()transformation = estimator.create_transformation()predictor = estimator.create_predictor(transformation, lightning_module)forecast_it, ts_it = make_evaluation_predictions(dataset=dataset,predictor=predictor,num_samples=num_samples)forecasts = list(forecast_it)tss = list(ts_it)return forecasts, tssimport pandas as pd
from gluonts.dataset.pandas import PandasDataseturl = ("/lag-llama/history.csv"
)
df = pd.read_csv(url, index_col=0, parse_dates=True)# Set numerical columns as float32
for col in df.columns:# Check if column is not of string typeif df[col].dtype != 'object' and pd.api.types.is_string_dtype(df[col]) == False:df[col] = df[col].astype('float32')# Create the Pandas
dataset = PandasDataset.from_long_dataframe(df, target="target", item_id="item_id")backtest_dataset = dataset
# 预测长度
prediction_length = 24  # Define your prediction length. We use 24 here since the data is of hourly frequency
# 样本数
num_samples = 1  # number of samples sampled from the probability distribution for each timestep
device = torch.device("cuda:1")  # You can switch this to CPU or other GPUs if you'd like, depending on your environmentforecasts, tss = get_lag_llama_predictions(backtest_dataset, prediction_length, device, num_samples)# 提取第一个时间序列的预测结果
forecast = forecasts[0]
print('=================================')
# 概率预测的完整样本(形状: [num_samples, prediction_length])
samples = forecast.samples
print(samples)

关键参数说明:

参数

说明

prediction_length

预测的未来时间步长

context_length

模型输入的历史时间步长(需 >= 季节性周期)

num_samples

概率预测的采样次数(值越大,概率区间越准)

checkpoint_path

预训练模型权重路径(需提前下载)

freq

时间序列频率(如 "H" 小时、"D" 天)

结果:

这里只是给出了简单的代码实现,想要更好的效果还需深入研究!!!

http://www.dtcms.com/wzjs/424846.html

相关文章:

  • java开发工程师工资一般多少seo模拟点击有用吗
  • win7电脑做网站服务器人工智能培训班收费标准
  • 做网站用的图片网站推广方式
  • 做黏土的网站谷歌浏览器下载安装2023最新版
  • 贵阳专业做网站的公司有哪些制作小程序的软件
  • 网站登录怎么保存用户名密码海淀seo搜索优化多少钱
  • 做外贸用什么网站好网站注册步骤
  • 政府网站后台如何管理十大免费cms建站系统介绍
  • 微信推广网站建设app拉新推广代理平台
  • 珠海做网站的公司打开全网搜索
  • 昆明app开发制作黑帽seo技术有哪些
  • 数学家 wordpressseo是干嘛的
  • 半瓶的wordpress之旅论坛seo招聘
  • 做网站业务员如何跟客户沟通网站超级外链
  • 福州+网站建设+医疗如何建立自己的网站?
  • 做网站的框架模版怎么开发一个网站
  • 徐州 网站 备案 哪个公司做的好做网站关键词优化的公司
  • 学技术包分配的培训机构网络优化工作应该怎么做
  • 手机端网站尺寸规范西安百度推广优化
  • 网站开发案例教堂html佛山网站优化排名推广
  • 做网站反应快的笔记本有哪些长沙seo行者seo09
  • 上海浦东新区疫情专业网站优化公司
  • 网站开发环境的安装说明网站秒收录
  • 日本网站做任务关键字排名优化公司
  • 适合宝妈做兼职的网站网站优化费用报价明细
  • 做网站 视频外链昆明长尾词seo怎么优化
  • 怎么做百度推广网站搜索优化seo
  • 烟台产品网站建设搜索引擎主要包括三个部分
  • twenty ten wordpressseo排名优化服务
  • 南昌建网站的公司关键词排名推广