AWSDeepAR模型是否有简单的训练方法?
创始人
2024-09-24 19:30:29
0

在AWS中,有多种方式可以训练DeepAR模型,其中最简单的方法是使用Jupyter Notebook来演示构建和测试模型的过程。这里提供了一个基于Python的示例代码:

import pandas as pd
from datetime import datetime
import numpy as np
import json

import boto3
import sagemaker

session = sagemaker.Session() 

s3_bucket = '' 
s3_prefix = 'deep_ar_demo'

# Use the region-specific AWS DeepAR image.
region_name = boto3.Session().region_name
image_name = '329769244726.dkr.ecr.{}.amazonaws.com/deepar:latest'.format(region_name)

# Create the estimator
estimator = sagemaker.estimator.Estimator(
    sagemaker.image_uris.retrieve(image_name, region=session.boto_region_name),
    role=sagemaker.get_execution_role(),
    instance_count=1,
    instance_type='ml.c4.2xlarge',
    output_path='s3://{}/{}/output'.format(s3_bucket, s3_prefix),
)

# Setup HyperParameters
# Adjust the hyperparameters for your specific use-case.
freq = 'H'
prediction_length = 24
context_length = 48
epochs = 10
learning_rate = .001
num_cells = 40
num_layers = 2
dropout_rate = .1
batch_size = 32

hyperparameters = {
    "time_freq": freq,
    "epochs": str(epochs),
    "early_stopping_patience": "10",
    "context_length": str(context_length),
    "prediction_length": str(prediction_length),
    "learning_rate": str(learning_rate),
    "num_cells": str(num_cells),
    "num_layers": str(num_layers),
    "dropout_rate": str(dropout_rate),
    "mini_batch_size": str(batch_size),
}

estimator.set_hyperparameters(**hyperparameters)

# Train model
data_channels = {
    "train": "s3://{}/{}/train/".format(s3_bucket, s3_prefix),
    "test": "s3://{}/{}/test/".format(s3_bucket, s3_prefix)
}

estimator.fit(inputs=data_channels)

相关内容

热门资讯

记者揭秘!智星菠萝辅助(透视辅... 记者揭秘!智星菠萝辅助(透视辅助)拱趴大菠萝辅助神器,扑克教程(有挂细节);模式供您选择,了解更新找...
一分钟揭秘!约局吧能能开挂(透... 一分钟揭秘!约局吧能能开挂(透视辅助)hhpoker辅助靠谱,2024新版教程(有挂教学);约局吧能...
透视辅助!wepoker模拟器... 透视辅助!wepoker模拟器哪个好用(脚本)hhpoker辅助挂是真的,科技教程(有挂技巧);囊括...
透视代打!hhpkoer辅助器... 透视代打!hhpkoer辅助器视频(辅助挂)pokemmo脚本辅助,2024新版教程(有挂教程);风...
透视了解!约局吧德州真的有透视... 透视了解!约局吧德州真的有透视挂(透视脚本)德州局HHpoker透视脚本,必胜教程(有挂分析);亲,...
六分钟了解!wepoker挂底... 六分钟了解!wepoker挂底牌(透视)德普之星开辅助,详细教程(有挂解密);德普之星开辅助是一种具...
9分钟了解!wpk私人辅助(透... 9分钟了解!wpk私人辅助(透视)hhpoker德州透视,插件教程(有挂教学);风靡全球的特色经典游...
推荐一款!wepoker究竟有... 推荐一款!wepoker究竟有透视(脚本)哈糖大菠萝开挂,介绍教程(有挂技术);囊括全国各种wepo...
每日必备!wepoker有人用... 每日必备!wepoker有人用过(脚本)wpk有那种辅助,线上教程(有挂规律);wepoker有人用...
玩家必备教程!wejoker私... 玩家必备教程!wejoker私人辅助软件(脚本)哈糖大菠萝可以开挂,可靠技巧(有挂神器)申哈糖大菠萝...