

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 内置算法的日志
<a name="common-info-all-sagemaker-models-logs"></a>

Amazon SageMaker AI 算法会生成亚马逊 CloudWatch 日志，这些日志提供有关训练过程的详细信息。要查看日志，请在 Amazon 管理控制台中选择 **CloudWatch**，选择**日志**，然后选择/ aws/sagemaker/TrainingJobs **日志组**。在用于训练的每个节点上，每个训练作业都有一个日志流。日志流的名称以创建作业时在 `TrainingJobName` 参数中指定的值开头。

**注意**  
如果作业失败且日志未显示在中 CloudWatch，则很可能在训练开始之前发生了错误。原因包括指定了错误的训练镜像或 S3 位置。

日志的内容因算法而异。不过，您通常可以找到以下信息：
+ 日志开头部分提供的参数的确认
+ 训练期间出现的错误
+ 衡量算法的准确率或数字性能
+ 算法的计时，以及算法中的任何主要阶段

## 常见错误
<a name="example-errors"></a>

如果训练作业失败，则训练作业描述中的 `FailureReason` 返回值会提供有关失败情况的一些详细信息，如下所示：

```
sage = boto3.client('sagemaker')
sage.describe_training_job(TrainingJobName=job_name)['FailureReason']
```

其他则仅在 CloudWatch 日志中报告。常见错误包括：

1. 错误指定了超参数，或指定的超参数对于算法无效。

   **来自日 CloudWatch 志**

   ```
   [10/16/2017 23:45:17 ERROR 139623806805824 train.py:48]
   Additional properties are not allowed (u'mini_batch_siz' was
   unexpected)
   ```

1. 为超参数指定的值无效。

   **FailureReason**

   ```
   AlgorithmError: u'abc' is not valid under any of the given
   schemas\n\nFailed validating u'oneOf' in
   schema[u'properties'][u'feature_dim']:\n    {u'oneOf':
   [{u'pattern': u'^([1-9][0-9]*)$', u'type': u'string'},\n
   {u'minimum': 1, u'type': u'integer'}]}\
   ```

   **FailureReason**

   ```
   [10/16/2017 23:57:17 ERROR 140373086025536 train.py:48] u'abc'
   is not valid under any of the given schemas
   ```

1. protobuf 文件格式不正确。

   **来自日 CloudWatch 志**

   ```
   [10/17/2017 18:01:04 ERROR 140234860816192 train.py:48] cannot
                      copy sequence with size 785 to array axis with dimension 784
   ```