Skip to content

Instantly share code, notes, and snippets.

View siakon89's full-sized avatar

Siaterlis Konstantinos siakon89

View GitHub Profile
{"lastUpload":"2021-04-11T06:50:47.971Z","extensionVersion":"v3.4.3"}
predictor = estimator.deploy(
initial_instance_count=1,
instance_type='ml.p2.xlarge',
endpoint_name="no-elastic-inference-test"
)
predictor = estimator.deploy(
initial_instance_count=1,
instance_type='ml.c5.large',
accelerator_type='ml.eia1.medium',
estimator = TensorFlow(
entry_point='model.py', # Script that has the model
train_instance_type='ml.p3.2xlarge', # The instance type for training
train_instance_count=1, # The number of instances to be spawned
model_dir='/opt/ml/model', # The location for the trained model
hyperparameters={ # Hyperparameters for the model
'epochs': 250,
'batch_size': 128,
'learning_rate': 0.001
},
from sagemaker.debugger import Rule, rule_configs
estimator = TensorFlow(
entry_point='model.py',
train_instance_type=train_instance_type,
train_instance_count=1,
model_dir=model_dir,
hyperparameters=hyperparameters,
role=sagemaker.get_execution_role(),
base_job_name='tf-fashion-mnist',
from smdebug.trials import create_trial
from smdebug import modes
import numpy as np
import matplotlib.pyplot as plt
# Get the tensors from S3
s3_output_path = estimator.latest_job_debugger_artifacts_path()
# Create a Trial https://github.com/awslabs/sagemaker-debugger/blob/master/docs/analysis.md#Trial
debugger_hook_config = DebuggerHookConfig(
s3_output_path=f"s3://{bucket}/fashion-mnist/hook",
collection_configs=[
CollectionConfig(
name="all_tensors",
parameters={
"include_regex": ".*",
"save_steps": "1, 2, 3"
}
)
hyperparameters = {'epochs': 10, 'batch_size': 256, 'learning_rate': 0.001}
estimator = TensorFlow(
entry_point='model.py',
train_instance_type='ml.p3.2xlarge',
train_instance_count=1,
model_dir='/opt/ml/model',
hyperparameters=hyperparameters,
role=sagemaker.get_execution_role(),
base_job_name='tf-fashion-mnist',
from sagemaker.debugger import CollectionConfig, DebuggerHookConfig
bucket = sess.default_bucket()
collection_config_biases = CollectionConfig(name='biases')
collection_config_weights = CollectionConfig(name='weights')
collection_config_metrics = CollectionConfig(name='metrics')
debugger_hook_config = DebuggerHookConfig(
s3_output_path=f"s3://{bucket}/fashion-mnist/hook",
sam build
sam package --output-template-file .aws-sam/packaged.yaml --s3-bucket <a bucket to save the template> --profile <your profile name>
sam deploy --template-file .aws-sam/packaged.yaml --stack-name imageTagging --capabilities CAPABILITY_IAM --profile <your profile name>
import boto3
from boto3.s3.transfer import TransferConfig
BUCKET = "<your bucket from SAM template>"
REGION = "<your region>"
PROFILE = "<your profile>"
def upload_to_s3(file_name, key, bucket=BUCKET, region=REGION):