<p>You are mixing two different versions of DeepAR, that's why you have errors. <a href="https://arxiv.org/abs/1704.04110" rel="nofollow noreferrer">DeepAR (Salinas et al.)</a> is actually implemented in 3 places:</p>
<ol>
<li>In <strong><a href="https://docs.aws.amazon.com/forecast/latest/dg/aws-forecast-recipe-deeparplus.html" rel="nofollow noreferrer">Amazon Forecast</a></strong>: DeepAR+ is a managed implementation of DeepAR, where all the science code is written for you and you only need to use Forecast SDK to launch the service on your S3 data. (<a href="https://github.com/aws-samples/amazon-forecast-samples/blob/master/notebooks/advanced/Getting_started_with_DeepAR%2B/Getting_started_with_DeepAR%2B.ipynb" rel="nofollow noreferrer">example</a>). Use Amazon Forecast if you do not want to write any scientific code and want a managed experience.</li>
<li>In <strong><a href="https://docs.aws.amazon.com/sagemaker/latest/dg/deepar.html" rel="nofollow noreferrer">Amazon SageMaker</a></strong>: SageMaker has a built-in DeepAR container, that you can use to train on S3 data. See <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/deepar_hyperparameters.html" rel="nofollow noreferrer">here the available hyperparameters</a>, and <a href="https://github.com/aws/amazon-sagemaker-examples/blob/master/introduction_to_amazon_algorithms/deepar_electricity/DeepAR-Electricity.ipynb" rel="nofollow noreferrer">here examples</a>. Use SageMaker DeepAR if you want more control, while still not having to write model code (more hyperparameters, hardware choice)</li>
<li><strong><a href="https://ts.gluon.ai/" rel="nofollow noreferrer">In open-source GluonTS</a></strong>: The GluonTS open-source neural forecasting library created by AWS comes with an implementation of DeepAR (<a href="https://aws.amazon.com/blogs/machine-learning/creating-neural-time-series-models-with-gluon-time-series/" rel="nofollow noreferrer">example</a>). Because it's open-source, you can use it for free, you can browse the code and install it anywhere compatible. For example, you can use the GluonTS DeepAR in a SageMaker container (<a href="https://aws.amazon.com/blogs/machine-learning/training-debugging-and-running-time-series-forecasting-models-with-the-gluonts-toolkit-on-amazon-sagemaker/" rel="nofollow noreferrer">blog post</a>). <a href="https://towardsdatascience.com/deep-demand-forecasting-with-amazon-sagemaker-e0226410763a" rel="nofollow noreferrer">This blog post</a> shows a GluonTS LSTNet model in a SageMaker container. Use GluonTS if you want more freedom. But remember that with more freedom comes more responsibility: you will have to choose the training and inference hardware and write science and orchestration code.</li>
</ol>
<p>There is no evidence that those 3 implementations of DeepAR have anything in common (beyond coming from AWS), their codebases may be different.</p>
<p>In order to run hyperparameter tuning with DeepAR you have several options:</p>
<ol>
<li>In Amazon Forecast: use the <a href="https://docs.aws.amazon.com/forecast/latest/dg/API_HyperParameterTuningJobConfig.html" rel="nofollow noreferrer">HyperparameterTuningJobConfig</a></li>
<li>In Amazon SageMaker DeepAR: use SageMaker Model Tuning, <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/deepar-tuning.html" rel="nofollow noreferrer">as explained here</a></li>
<li>With GluonTS in Amazon SageMaker: use SageMaker Model Tuning with a custom metric.</li>
<li>With GluonTS out of SageMaker: use the hyperparameter tuning library of your choice (<a href="https://docs.ray.io/en/master/tune/index.html" rel="nofollow noreferrer">RayTune</a>, <a href="https://optuna.org/" rel="nofollow noreferrer">Optuna</a>,...) on the infrastructure of your choice</li>
</ol>
Amazon DeepAR Hyperparameters tuning error
<p>This is what I got after running the code:</p>
<p>File &quot;C:\Users\admin\anaconda3\envs\tensorflow_env\lib\site-packages\sagemaker\tuner.py&quot;, line 484, in _prepare_estimator_for_tuning estimator._prepare_for_training(job_name)</p>
<p>AttributeError: 'DeepAREstimator' object has no attribute '_prepare_for_training'</p>
<p>It seems that very few examples of hyperparameters tuning about Amazon sagemaker deepar algorithm are available on the internet. Can anybody help me with this issue ?</p>
<pre><code>import mxnet as mx
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from gluonts.model.deepar import DeepAREstimator
from gluonts.mx.trainer import Trainer
from gluonts.dataset.common import ListDataset
from itertools import islice
from gluonts.evaluation.backtest import make_evaluation_predictions
from sagemaker.tuner import HyperparameterTuner, IntegerParameter, CategoricalParameter, ContinuousParameter

df = pd.read_csv('final.csv', index_col=0,parse_dates=True)
                        
training_data = ListDataset(
    [{&quot;start&quot;: df.index[0], &quot;target&quot;: df.outbound_qty[:pd.to_datetime('2021-01-01')],
      &quot;feat_dynamic_real&quot;: [df.is_holiday[:pd.to_datetime('2021-01-01')],
                            df.is_salary[:pd.to_datetime('2021-01-01')],
                            df.count_qty[:pd.to_datetime('2021-01-01')],
                            df.shelf_qty[:pd.to_datetime('2021-01-01')]]
      }],
    freq=&quot;D&quot;
)

estimator = DeepAREstimator(freq=&quot;D&quot;,prediction_length=7,trainer=Trainer(ctx=mx.context.cpu()))

hyperparams = {'learning_rate': ContinuousParameter(0.001, 0.1),
                'epochs': IntegerParameter(10, 100),
                'context_length': IntegerParameter(7, 90),
                'mini_batch_size': IntegerParameter(32, 128)
                }

tuner = HyperparameterTuner(estimator=estimator,  objective_metric_name=&quot;test:RMSE&quot;,
                        objective_type='Minimize',hyperparameter_ranges=hyperparams)

tuner.fit(inputs = training_data)
</code></pre>