Upload
others
View
23
Download
0
Embed Size (px)
Citation preview
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
今から始める機械学習入門
Amazon SageMakerの初級活用方法
大渕麻莉
アマゾンウェブサービスジャパン
機械学習ソリューションアーキテクト
TWITTERハッシュタグ #AWSInnovate
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
自己紹介
大渕麻莉(おおぶちまり)
機械学習ソリューションアーキテクト
前職はスタートアップで機械学習(ML)
前々職はカメラメーカで画像処理とML
好きなAWSサービスは、
Amazon SageMaker
Amazon EC2
3
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
本セッションの Goal
機械学習を使ったプロダクトやサービスを作りたいお客様が、
自分で機械学習アルゴリズムを開発することなく、
Amazon SageMakerで機械学習を行う方法を会得する
4
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
本セッションの概要
Amazon SageMakerを使った機械学習の紹介
Amazon SageMakerにあらかじめ用意されているアルゴリズム、
ビルトインアルゴリズムの紹介
サンプルノートブックを使って、
ビルトインアルゴリズムの基本的な使い方の紹介
AWS Marketplaceの紹介
5
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
AWSの機械学習サービススタック
フレームワーク インターフェース コンピュート基盤
AI (Artificial Intelligence) サービス
画像 音声 自然言語 チャットボット 予測 リコメンド
ML (Machine Learning) サービス
ML フレームワーク + インフラストラクチャ
P O L L Y T R A N S C R I B E T R A N S L A T E C O M P R E H E N D L E X F O R E C A S TR E K O G N I T I O N
I M A G E
R E K O G N I T I O N
V I D E O T E X T R A C T P E R S O N A L I Z E
Ground Truth Notebooks Algorithms + Marketplace Reinforcement Learning Training Optimization Deployment HostingAmazon SageMaker
F P G A SE C 2 P 3
& P 3 D N
E C 2 G 4 E C 2 C 5 I N F E R E N T I AG R E E N G R A S S E L A S T I C
I N F E R E N C E
7
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
AI サービスの特徴
• データを用意するだけ
8
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
ML サービス Amazon SageMakerの特徴
• ニーズに応じた独自の機械学習サービスの実装をサポート
• Amazon SageMaker
Model
Train
9
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Amazon SageMaker とは
• 機械学習プロジェクトの課題を解決するためのマネージドサービス
• 数分で開発環境を起動でき、学習、推論環境は柔軟にスケール
• 多数のAPIを提供しており、他サービスとの自由度の高い連携が可能
• 東京を含む 17リージョンで提供
• ほとんどのコンテナ、SDKはオープンソース
ラベリング 開発 学習 モデル変換 推論
11
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Amazon SageMaker のアーキテクチャ
ノートブックインスタンス
学習用インスタンス
推論用インスタンス
クライアント
SageMaker Service
Amazon S3
Amazon ECR
AWS CloudOffice
Network
12
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Amazon SageMaker での開発フロー(コード開発)
学習用インスタンス
推論用インスタンス
Amazon S3
ノートブックインスタンス
クライアント
AWS CloudOffice
Network
Amazon ECR
SageMaker Service
学習・推論用コード開発
13
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Amazon SageMaker での開発フロー(学習準備)
推論用インスタンス
Amazon S3学習用インスタンス
Amazon ECR
クライアント
Office
NetworkAWS Cloud
・学習用インスタンス起動・コンテナイメージのロード
SageMaker Service
ノートブックインスタンス
14
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Amazon ECR
Amazon SageMaker での開発フロー(学習)
推論用インスタンス
学習用インスタンス
Amazon S3
ノートブックインスタンス
クライアント
AWS CloudOffice
NetworkSageMaker Service
S3のデータで学習を実行
15
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Amazon ECR
Amazon SageMaker での開発フロー(学習完了)
推論用インスタンス
学習用インスタンス
Amazon S3
ノートブックインスタンス
クライアント
AWS CloudOffice
NetworkSageMaker Service
自動削除
モデルとコード自動保存
16
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
学習用インスタンス
Amazon SageMaker での開発フロー(推論準備)
Amazon S3
Amazon ECR
クライアント
Office
NetworkAWS Cloud
SageMaker Service
推論用インスタンス
・推論用インスタンス起動・コンテナイメージのロード
ノートブックインスタンス
17
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Amazon ECR
学習用インスタンス
ノートブックインスタンス
Amazon SageMakerでの開発フロー(推論)
クライアント
Office
NetworkAWS Cloud
SageMaker Service
推論用インスタンス
モデルとコードから推論用エンドポイント作成
Amazon S3
18
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
ビルトインアルゴリズム
• Linear Learner
• XGBoost
• k-means
• k-NN
• PCA
• Object2Vec
• Factorization Machines
https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html
画像
• Image Classification
• Object Detection
• Semantic Segmentation
数値・系列解析
• DeepAR Forecasting
• Random Cut Forest
• IP Insights
自然言語
• seq2seq
• LDA
• Neural Topic Model
• BlazingText
レコメンデーション
回帰・分類ほか
20
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Image Classification
ILSVRC 2015で優勝した ResNetによる高精度な画像認識
AWS が学習済みのモデルを提供しており、
ユーザ固有のデータに合わせて追加学習(転移学習)が可能
https://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/image-classification.html
dog cat
21
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Image Classificationの入出力インタフェース
5 1 your_image_directory/train_img_dog1.jpg
1000 0 your_image_directory/train_img_cat1.jpg
22 1 your_image_directory/train_img_dog2.jpg
https://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/image-classification.html
入力インタフェース
イメージ形式(lstファイルと画像)
RecordIO形式
拡張マニフェストイメージ形式
出力インタフェース
JSON 形式
JSON Lines 形式画像のインデックス、分類のインデックス、画像の相対パス
22
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
サンプルノートブックの GitHub Repository
https://github.com/awslabs/amazon-sagemaker-examples
ビルトインアルゴリズムのノートブックはIntroduction_to_amazon_algorithmsにある。
24
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
ノートブックインスタンスを作成する
25
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
26
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
サンプルノートブックを探す
27
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
28
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
サンプルノートブックの大まかな流れ
30
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
サンプルノートブックを開いて実行する
転移学習
31
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
32
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
環境の下準備とコンテナイメージの取得
33
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
画像データセットとツールのダウンロード
34
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
データを学習用と検証用に分割
35
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
データを S3にアップロード
36
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
学習準備
37
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
ハイパーパラメタの設定
38 https://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/IC-Hyperparameter.html
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
入力データ設定と学習開始
39
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
[解説] Amazon SageMaker内部で行われていること
推論用インスタンス
学習用インスタンス
Amazon S3
ノートブックインスタンス
クライアント
AWS CloudOffice
NetworkSageMaker Service
(2) lstファイル、画像
Amazon ECR
(3) 学習
(1) 画像分類コンテナ
40
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
推論用エンドポイント起動
41
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
推論の実行
42
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
推論エンドポイントの削除
43
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Amazon SageMakerの課金対象のリソース
44 https://docs.aws.amazon.com/ja_jp/sagemaker/latest/dg/ex1-cleanup.html
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
サンプルノートブックの大まかな流れ
45
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
ノートブック実行時の注意点
https://docs.aws.amazon.com/ja_jp/general/latest/gr/aws_service_limits.html
46
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
AWS Marketplace
48
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
モデルの価格
49
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
モデルの購入方法
50
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
購入したモデルの使い方
51
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
購入したモデルのエンドポイント作成
52
AWS Marketplace では、学習済みモデルと、学習が必要なモデルがある。
学習済みモデルを購入した場合は、すぐに推論に使用することが可能。
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
AWS Marketplace のメリット
53
購入者は機械学習で使用するデータを秘匿したままでモデルを使用でき、
販売者はモデルの中身を秘匿したままでモデルを販売できる。
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
まとめ
• 3 層の機械学習サービススタックで示したように、
AWS は成熟した機械学習サービスを幅広く提供
• Amazon SageMakerでは,
ビルトインアルゴリズムや AWS Marketplaceによって、
自分でモデルを開発することなく機械学習を使用可能
• 素早くビルトインアルゴリズムの使い方を学べる
サンプルノートブックを提供
55
Thank you!
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
Mari Ohbuchi
Thank you!
© 2019、 Amazon Web Services、 Inc. or its affiliates. All rights reserved.
- Events
- Webinar
- Archive