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)

相关内容

热门资讯

关于!微信微乐自建房辅助工具,... 关于!微信微乐自建房辅助工具,微乐家乡麻将自建房辅助app(开挂自建房)方法1)微乐家乡麻将自建房辅...
大家学习交流!微信卡五星辅助器... 大家学习交流!微信卡五星辅助器,微乐小程序免费黑科技(开挂自建房)方法1、很好的工具软件,可以解锁游...
三分钟了解!微乐微信自建房辅助... 三分钟了解!微乐微信自建房辅助工具插件,微乐家乡麻将自建房辅助app(开挂自建房)工具1、三分钟了解...
一分钟教会你!微乐家乡麻将自建... 一分钟教会你!微乐家乡麻将自建房辅助app,微乐自建房脚本免费入口(开挂自建房)方法1、用户打开应用...
分享实测!微信微乐自建房辅助工... 分享实测!微信微乐自建房辅助工具,微乐自建房脚本免费入口(开挂自建房)器1、起透看视 微信微乐自建房...
重大通报!微乐自建房辅助工具脚... 重大通报!微乐自建房辅助工具脚本,微乐小程序免费黑科技(开挂自建房)app微乐自建房辅助工具脚本破解...
如何分辨真伪!微乐微信自建房辅... 如何分辨真伪!微乐微信自建房辅助工具插件,微乐小程序免费黑科技(开挂自建房)技巧1、微乐微信自建房辅...
我来教教你!微乐自建房辅助工具... 我来教教你!微乐自建房辅助工具挂,微乐家乡麻将自建房辅助app(开挂自建房)工具1、玩家可以在微乐家...
重大来袭!微乐自建房辅助工具神... 重大来袭!微乐自建房辅助工具神器,微乐小程序免费黑科技(开挂自建房)器1、游戏颠覆性的策略玩法,独创...
带你了解!微信卡五星辅助器,微... 带你了解!微信卡五星辅助器,微乐自建房脚本免费入口(开挂自建房)方法1、带你了解!微信卡五星辅助器,...