MLS-C01 Machine Learning Implementation and Operations • Complete Question Bank
Complete MLS-C01 Machine Learning Implementation and Operations question bank — all 0 questions with answers and detailed explanations.
Refer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateTrainingJob",
"sagemaker:CreateModel",
"sagemaker:CreateEndpointConfig",
"sagemaker:CreateEndpoint"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::company-bucket/*"
}
]
}Refer to the exhibit.
resource "aws_sagemaker_notebook_instance" "ml_notebook" {
name = "my-notebook"
role_arn = "arn:aws:iam::123456789012:role/sagemaker-role"
instance_type = "ml.t2.medium"
direct_internet_access = "Enabled"
}Refer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sagemaker:CreateTrainingJob",
"Resource": "*",
"Condition": {
"StringEquals": {
"sagemaker:TrainingJobName": "*production*"
}
}
},
{
"Effect": "Deny",
"Action": "sagemaker:CreateTrainingJob",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"sagemaker:TrainingJobName": "*production*"
}
}
}
]
}Refer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateModel",
"sagemaker:CreateEndpointConfig",
"sagemaker:CreateEndpoint",
"sagemaker:InvokeEndpoint"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::123456789012:role/SageMakerExecutionRole",
"Condition": {
"StringEquals": {
"iam:PassedToService": "sagemaker.amazonaws.com"
}
}
},
{
"Effect": "Deny",
"Action": [
"sagemaker:DeleteEndpoint",
"sagemaker:DeleteEndpointConfig",
"sagemaker:DeleteModel"
],
"Resource": "*"
}
]
}Drag steps to the numbered slots on the right, or tap a step then tap a slot.
Drag steps to the numbered slots on the right, or tap a step then tap a slot.
Drag a concept onto its matching description — or click a concept then click the description.
Gradient boosted trees for regression and classification
Word2Vec and text classification
Learning embeddings for pairs of objects
Anomaly detection in IP traffic
Time series forecasting
Drag a concept onto its matching description — or click a concept then click the description.
Fraction of correct predictions on validation set
Root mean square error on validation set
Area under ROC curve on validation set
Logistic loss on validation set
Harmonic mean of precision and recall on validation set
Refer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
},
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateTrainingJob",
"sagemaker:DescribeTrainingJob"
],
"Resource": "*"
}
]
}Refer to the exhibit. 2023-01-15 10:30:00 ERROR - Model server did not start within 300 seconds. 2023-01-15 10:30:00 ERROR - No worker process responded to ping. 2023-01-15 10:30:00 INFO - Starting model server... 2023-01-15 10:29:55 INFO - Loading model from /opt/ml/model
Refer to the exhibit.
```
aws sagemaker create-training-job \
--training-job-name my-training \
--algorithm-specification TrainingImage=... \
--role-arn arn:aws:iam::123456789012:role/SageMakerRole \
--input-data-config [{"ChannelName":"train","DataSource":{"S3DataSource":{"S3Uri":"s3://bucket/data","S3DataType":"S3Prefix"}}}] \
--output-data-config {"S3OutputPath":"s3://bucket/output"} \
--resource-config {"InstanceCount":2,"InstanceType":"ml.m5.large","VolumeSizeInGB":10}
```Refer to the exhibit.
```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
},
{
"Effect": "Deny",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "AES256"
}
}
}
]
}
```Refer to the exhibit. ``` [Container] 2022/08/10 12:00:00 Starting inference server [Container] 2022/08/10 12:00:05 Model server started [Container] 2022/08/10 12:00:10 Invoking /invocations endpoint [Container] 2022/08/10 12:00:15 ERROR: Exception during prediction: OutOfMemoryError [Container] 2022/08/10 12:00:16 Shutting down ```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateEndpoint",
"sagemaker:InvokeEndpoint",
"cloudwatch:PutMetricData"
],
"Resource": "*"
}
]
}aws sagemaker create-training-job \
--training-job-name my-job \
--algorithm-specification TrainingImage=my-image,TrainingInputMode=File \
--resource-config InstanceType=ml.m5.large,InstanceCount=1,VolumeSizeInGB=30 \
--input-data-config ChannelName=training,DataSource={S3DataSource={S3Uri=s3://bucket/data,S3DataType=S3Prefix,S3DataDistributionType=FullyReplicated}} \
--output-data-config S3OutputPath=s3://bucket/output \
--stopping-condition MaxRuntimeInSeconds=36002019-10-12 15:30:01 - ERROR - Model prediction failed: Input shape mismatch. Expected (None, 10), got (None, 8).
Refer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::my-bucket/*"
},
{
"Effect": "Allow",
"Action": ["sagemaker:CreateTrainingJob"],
"Resource": "*"
}
]
}Refer to the exhibit. [2019-10-01 12:00:00] Training job started. [2019-10-01 12:05:00] Epoch 1/10: loss=2.3456, accuracy=0.5432 [2019-10-01 12:10:00] Epoch 2/10: loss=1.2345, accuracy=0.6543 [2019-10-01 12:15:00] Epoch 3/10: loss=0.9876, accuracy=0.7654 [2019-10-01 12:20:00] Epoch 4/10: loss=0.8765, accuracy=0.7890 [2019-10-01 12:25:00] Epoch 5/10: loss=0.7654, accuracy=0.8123 [2019-10-01 12:30:00] Epoch 6/10: loss=0.6543, accuracy=0.8345 [2019-10-01 12:35:00] Epoch 7/10: loss=0.5432, accuracy=0.8567 [2019-10-01 12:40:00] Epoch 8/10: loss=0.4321, accuracy=0.8789 [2019-10-01 12:45:00] Epoch 9/10: loss=0.3210, accuracy=0.9012 [2019-10-01 12:50:00] Epoch 10/10: loss=0.2109, accuracy=0.9234 [2019-10-01 12:55:00] Training job completed.
Refer to the exhibit.
{
"AlgorithmSpecification": {
"TrainingImage": "382416733822.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.2-1",
"TrainingInputMode": "File"
},
"RoleArn": "arn:aws:iam::123456789012:role/SageMakerRole",
"InputDataConfig": [
{
"ChannelName": "train",
"DataSource": {
"S3DataSource": {
"S3DataType": "S3Prefix",
"S3Uri": "s3://my-bucket/train/"
}
},
"ContentType": "text/csv",
"CompressionType": "None"
}
],
"OutputDataConfig": {
"S3OutputPath": "s3://my-bucket/output/"
},
"ResourceConfig": {
"InstanceType": "ml.m5.large",
"InstanceCount": 1,
"VolumeSizeInGB": 10
},
"StoppingCondition": {
"MaxRuntimeInSeconds": 86400
}
}{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateEndpoint",
"sagemaker:InvokeEndpoint"
],
"Resource": "arn:aws:sagemaker:us-east-1:123456789012:endpoint/my-endpoint"
},
{
"Effect": "Deny",
"Action": "sagemaker:InvokeEndpoint",
"Resource": "*",
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16"
]
}
}
}
]
}2024-03-15 10:23:45,234 - root - ERROR - Failed to load model: 'NoneType' object has no attribute 'shape'
Traceback (most recent call last):
File "/opt/ml/code/inference.py", line 45, in model_fn
model = load_model(model_dir)
File "/opt/ml/code/inference.py", line 30, in load_model
input_shape = model.input_shape
AttributeError: 'NoneType' object has no attribute 'shape'AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyEndpoint:
Type: AWS::SageMaker::Endpoint
Properties:
EndpointName: my-endpoint
EndpointConfigName: !Ref MyEndpointConfig
MyEndpointConfig:
Type: AWS::SageMaker::EndpointConfig
Properties:
ProductionVariants:
- InitialInstanceCount: 2
InstanceType: ml.m5.large
ModelName: !Ref MyModel
VariantName: variant-1
MyModel:
Type: AWS::SageMaker::Model
Properties:
PrimaryContainer:
Image: 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-image:latest
ModelDataUrl: s3://my-bucket/model.tar.gz
ExecutionRoleArn: arn:aws:iam::123456789012:role/SageMakerRoleRefer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sagemaker:CreateTrainingJob",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}Refer to the exhibit.
{
"AlarmName": "HighLatency",
"MetricName": "ModelLatency",
"Namespace": "AWS/SageMaker",
"Statistic": "p99",
"Period": 60,
"EvaluationPeriods": 2,
"Threshold": 500,
"ComparisonOperator": "GreaterThanThreshold"
}{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
},
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateTrainingJob",
"sagemaker:CreateModel",
"sagemaker:CreateEndpointConfig",
"sagemaker:CreateEndpoint"
],
"Resource": "*"
}
]
}2023-01-01 12:00:00,000 - ERROR - Model prediction took 15 ms for request ID abc123
Refer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateTrainingJob",
"sagemaker:DescribeTrainingJob"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}Refer to the exhibit. 2023-01-01 12:00:00,123 INFO - Starting training 2023-01-01 12:00:01,456 ERROR - Unable to read data from /opt/ml/input/data/training 2023-01-01 12:00:01,457 INFO - Training completed
Refer to the exhibit.
{
"EndpointConfigName": "my-endpoint-config",
"ProductionVariants": [
{
"VariantName": "variant1",
"ModelName": "my-model",
"InitialInstanceCount": 1,
"InstanceType": "ml.m5.large"
}
]
}{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateModel",
"sagemaker:CreateEndpointConfig",
"sagemaker:CreateEndpoint"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage"
],
"Resource": "arn:aws:ecr:us-east-1:123456789012:repository/sagemaker-inference"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": "arn:aws:s3:::my-bucket/model/*"
}
]
}2023-01-15 10:30:45,123 INFO - Training job started 2023-01-15 10:30:50,567 INFO - Epoch 1/10: loss=2.345, accuracy=0.45 2023-01-15 10:31:00,789 INFO - Epoch 2/10: loss=2.123, accuracy=0.52 2023-01-15 10:31:10,012 INFO - Epoch 3/10: loss=1.987, accuracy=0.58 ... 2023-01-15 10:32:30,456 ERROR - OutOfMemoryError: CUDA out of memory. Tried to allocate 2.00 GiB (GPU 0; 15.90 GiB total capacity; 14.00 GiB already allocated; 1.50 GiB free; 14.10 GiB reserved in total by PyTorch) 2023-01-15 10:32:30,457 ERROR - Training terminated
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sagemaker:*",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket"
},
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::123456789012:role/SageMakerExecutionRole"
}
]
}Refer to the exhibit.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateTrainingJob",
"sagemaker:DescribeTrainingJob",
"sagemaker:StopTrainingJob",
"sagemaker:ListTrainingJobs"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}Refer to the exhibit. [ERROR] 2023-01-15 10:23:45,123 - sagemaker - Could not find model package with arn:aws:sagemaker:us-east-1:123456789012:model-package/my-model/1
Refer to the exhibit.
{
"ContainerDefinitions": [
{
"Image": "123456789012.dkr.ecr.us-east-1.amazonaws.com/my-custom-image:latest",
"ModelDataUrl": "s3://my-bucket/model.tar.gz",
"Environment": {
"SAGEMAKER_PROGRAM": "train.py"
}
}
],
"InferenceSpecification": {
"Containers": [
{
"Image": "123456789012.dkr.ecr.us-east-1.amazonaws.com/my-custom-image:latest",
"ModelDataUrl": "s3://my-bucket/model.tar.gz",
"Environment": {}
}
]
}
}Refer to the exhibit.
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
},
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateTrainingJob",
"sagemaker:DescribeTrainingJob"
],
"Resource": "*"
}
]
}
```Refer to the exhibit. ``` 2024-01-15 10:23:45,123 - sagemaker - INFO - Training job created 2024-01-15 10:23:46,456 - sagemaker - INFO - Starting training... 2024-01-15 10:23:50,789 - root - ERROR - OSError: [Errno 28] No space left on device ```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sagemaker:CreateTrainingJob",
"sagemaker:DescribeTrainingJob"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": "arn:aws:s3:::my-bucket/training-data/*"
}
]
}A company uses Amazon SageMaker to train machine learning models. The data science team has developed a training script that uses TensorFlow. They want to run the training job on a GPU instance (ml.p3.2xlarge) and store the model artifact in Amazon S3. The training job completes successfully, but the model artifact is not saved to S3. The team has confirmed that the S3 bucket policy allows write access from the SageMaker execution role. The training script uses the TensorFlow estimator with the following configuration:
``` tensorflow_estimator = TensorFlow( entry_point='train.py', role='arn:aws:iam::123456789012:role/SageMakerExecutionRole', instance_count=1, instance_type='ml.p3.2xlarge', output_path='s3://my-bucket/output', framework_version='2.3', py_version='py37', ) ```
The train.py script saves the model using `model.save('/opt/ml/model')`. What is the MOST likely reason the model artifact is not being saved to S3?