Upgrade to Pro — share decks privately, control downloads, hide ads and more …

get-started-with-machine-learning-on-aws-20170401

 get-started-with-machine-learning-on-aws-20170401

IoT ALGYAN @ 20170401

ryo nakamaru

April 01, 2017
Tweet

More Decks by ryo nakamaru

Other Decks in Programming

Transcript

  1. y = ax + b ྫʣ x : ࠷ۙ஌Γ߹ͬͨਓͷಛ௃ y

    : ͜ͷͻͱͱকདྷ݁ࠗͨ͠Β޾ͤʹͳΕΔ͔ ػցֶशͱ͸ 9
  2. y = ax + b ྫʣ ਓؒʮ y = 0.7

    * ੑ֨x + 0.2 * ֎ݟx + 0.1 * ऩೖx ͰΑΖʯ ػցʮաڈͷσʔλ͔Β͍͑͹ ɹɹɹy = 0.4 * ੑ֨x + 0.1 * ֎ݟx + 0.5 * ऩೖx ͕ద੾ʯ ػցֶशͱ͸ 10
  3. y = ax + b a, b ΛܾΊΔͨΊͷ࡞ۀΛֶशɺ ܾ·ͬͨ a,

    b ͷ͜ͱΛֶशࡁΈϞσϧͱݴ͏ɻ ֶशࡁΈϞσϧΛ࢖ͬͯ ࣮ࡍʹ x Λ౤ೖ͠ y ΛಘΔͷ͕ਪ࿦ɻ ֶशͱਪ࿦ 11
  4. y = ax + b σʔλ͔Β a, b ΛؼೲతʹٻΊΔ۩ମతͳํ๏ͷ͜ͱɻ •

    A / B Ͳͬͪʁ໰୊ → ϩδεςΟοΫճؼ • ച্Λ༧ଌ͍ͨ͠ → ઢܗճؼ • ސ٬Ληάϝϯτ෼͚͍ͨ͠ → k ฏۉ๏ • ϨίϝϯυΛग़͍ͨ͠ → ڠௐϑΟϧλϦϯά • … ֶशΞϧΰϦζϜ 14
  5. ػցֶशશൠɺղܾ͍ͨ͠໰୊͝ͱʹબ୒͢Δͷ͕ ֶशΞϧΰϦζϜɻਂ૚ֶश΋ྫ֎Ͱ͸ͳ͍ɾɾ ྫʣ • ͜ͷ͖Ύ͏Γ͸ S? M? L? → ৞ΈࠐΈχϡʔϥϧωοτϫʔΫ

    (CNN) • ࠓͷൃݴ͸ϙδςΟϒʁ → ࠶ؼܕχϡʔϥϧωοτϫʔΫ (RNN) • ਓ͕ඈͼग़͖ͯͨ͠ʂंΛݮ଎ʂʂ → ͋Ε͜Ε૊Έ߹Θͤ • … ਂ૚ֶशΞϧΰϦζϜ 22
  6. ඒ͍͠૊Έ߹ΘͤͷྫɺAlphaGoɻ ʢ࿦จ: http://www.nature.com/nature/journal/v529/n7587/abs/nature16961.html ʣ • 4 ͭͷσΟʔϓχϡʔϥϧωοτϫʔΫΛར༻ • ͦΕͧΕ ॳڃऀ

    pπ / தڃऀ pσ / ্ڃऀ pρ / ৘੎൑அ vθ ͱ͍ͬͨҐஔ෇͚ • pπ ͸ਓؒͷ 800 ສͷ൫໘σʔλΛݩʹֶशɻਫ਼౓͸௿͍͕ߴ଎ʹղΛಘΔɻ • pσ ͸ 13 ૚ͷ CNNɻ3,000 ສ൫໘Λ 50 GPU Ͱ 3.4 ԯεςοϓɺ3 िֶؒशɻ ϓϩͷࢦ͠खΛ 57.0% ͷਫ਼౓Ͱ༧૝Ͱ͖Δɻ • pρ ͸ 50 GPU Ͱ 1 ೔͔͚128 ສճࣗݾରઓɻطଘιϑτʹ 85% ͷѹ౗తউ཰ɻ • vθ ͸ pσ ͰϥϯμϜʹ 3,000 ສ൫໘Λੜ੒͠ɺpρ Ͱ 1 ԯ 6,000 ສճϩʔϧΞ΢τͨ͠উ཰Λ ڭࢣσʔλʹɺ50 GPU ͰҰिؒ 5,000 ສճ֬཰ޯ഑߱Լ๏Λ࣮ࢪɻ • ࣮ରઓͰ͸1,202 CPU + 176 GPU͕࢖ΘΕɺpσ Ͱ࣍ͷखબ୒ɺvθ Ͱ൫໘ධՁɻ • উ཰͸͍͍͕ཧ٧Ίͷ pρ ΑΓɺਓؒͷบΛֶΜͩ pσ Λ࢖͔ͬͨɻ • উҼ͸ pρ ͷపఈతͳڧԽֶशʹՃ͑ɺϞϯςΧϧϩ໦୳ࡧͱ CNN ͷ૊߹͔ͤɻ ਂ૚ֶशΞϧΰϦζϜ 23
  7. TensorFlowɺMXNetɺCaffeɺChainerɺTheanoɾɾ ͦΕͧΕͷಛ௃ΛؑΈͯͲΕΛ࢖͏ͷ͔ɻ • ରԠΞϧΰϦζϜ • ಈ࡞୺຤ɾ؀ڥ • ܭࢉ଎౓ / Ϧιʔεར༻ޮ཰

    • ར༻Մೳͳݴޠ / खଓతɾએݴత • εέʔϥϏϦςΟ / ෳ਺ GPUɺฒྻαʔόରԠ • ৘ใͷ๛෋͞ / ΤίγεςϜ / ঎༻αϙʔτ • … ਂ૚ֶशϑϨʔϜϫʔΫ 30
  8. Ұൠެ։͞Εͨը૾ू ݚڀ΋ίϯςετ΋੝ΜͰɺͨ͘͞Μ͋Γ·͢ɻ • MNIST ɹ http://yann.lecun.com/exdb/mnist/ • CIFAR-10 & CIFAR-100

    ɹ https://www.cs.toronto.edu/~kriz/cifar.html • ImageNet ɹ http://www.image-net.org/ • … 44
  9. AWS

  10. σʔλऩूʹศརͳαʔϏε • AWS IoT • Amazon Kinesis Streams • Amazon

    CloudWatch Logs • Amazon S3 • Amazon DynamoDB • Amazon Cognito + AWS SDK • Amazon API Gateway 52
  11. σʔλલॲཧʹศརͳαʔϏε • Amazon Mechanical Turk • Amazon Athena • AWS

    Lambda / Step Functions • AWS CloudWatch Events • Amazon EMR / Batch / EC2 55
  12. (NVIDIA) GPU 61 ݱࡏ AWS Ͱ GPU Λ࢖͏ͱ͖ͷ Tips Λ·ͱΊ·ͨ͠

    https://speakerdeck.com/pottava/tesorflow-v1-dot-0-on-ec2
  13. NVIDIA ͷ Docker Πϝʔδ 64 ҎԼͷΑ͏ͳܧঝؔ܎ͷΠϝʔδ͕ެ։͞Ε͍ͯ·͢ɻ ػցֶशͷಈ࡞ཁ݅ʹదͨ͠ΠϝʔδΛϕʔεʹɻ ಠࣗ Docker ΠϝʔδͷϏϧυ΋Ͱ͖·͢ɻ

    cuda:7.x-runtime ubuntu:14.04 cuda:7.x-devel cuda:7.x-cudax-runtime cuda:7.x-cudax-devel caffe (v0.14) digits (v4.0)
  14. ࣮ࡍɺνʔϜͰݚڀɾ։ൃΛ͢ΔͱͳΔͱ ؀ڥͷ෼཭ / ෳ੡ / ڞ༗ / ݖݶ؅ཧͳͲ՝୊͸ͨ͘͞Μɻ ޙड़ͷ EMR

    or ECS + IAM ͳͲͷ૊Έ߹ΘͤΕ͹ ࠷৽ͷ GPU ؀ڥΛࣗಈ഑෍͢Δͱ͍ͬͨ͜ͱ΋ʂ AWS Ͱͷ෼ੳ؀ڥ 66
  15. ࢼߦࡨޡϑΣʔζʹศརͳαʔϏε • Amazon Machine Learning • Amazon EMR / EC2

    ‣ p2 / g2 (GPU) instances ‣ Deep Learning AMI • Amazon EBS / S3 / ECR 68
  16. GPU Πϯελϯε 70 AWS ʹ͸ 2 छྨ͋Γ·͢ʢݱߦੈ୅ʣ g2 ܥ: NVIDIA

    GRID K520 ɹɹɹɹ1,536 CUDA cores / GPU ͕ 2 ͭͰ 1 ͭͷ K520 ɹɹɹɹg2 Ͱ࢖͑Δ GPU ͸ຊདྷάϥϑΟοΫɾήʔϛϯά༻్ p2 ܥ: NVIDIA Tesla K80 ɹɹɹɹഒਫ਼౓ԋࢉ࠷େ 2.91 TFLOPSɺ୯ਫ਼౓ԋࢉ࠷େ 8.74 TFLOPS ɹɹɹɹ2,496 CUDA cores / GPU ͕ 2 ͭͰ 1 ͭͷ K80 ɹɹɹɹp2 ͷ GPU ͸൚༻ίϯϐϡʔςΟϯά༻్
  17. Amazon DeepLearning AMI 71 શ෦ೖΓ AMIɺ͋Γ·͢ʂʂ TensorFlow 1.0, MXNet, Caffe,

    CNTK, Theano, Torchɻ CUDA 7.5, cuDNN 5.0, Anaconda ΋ɻ
  18. ֶशϑΣʔζʹศརͳαʔϏε • Amazon EMR / Batch / EC2 ‣ p2

    / g2 (GPU) instances ‣ Deep Learning AMI ‣ Spot Fleet / AutoScaling Group • Amazon Machine Learning • Amazon EFS / EBS / S3 / ECR • Amazon SQS 75
  19. ਪ࿦ϑΣʔζʹศརͳαʔϏε • Amazon ECS / EC2 ‣ p2 / g2

    (GPU) instances ‣ Deep Learning AMI ‣ Spot Fleet / AutoScaling Group • AWS Lambda / Amazon API Gateway • AWS ElasticBeanstalk • Amazon EFS / EBS / S3 / ECR 82
  20. ίϯςϯπ • AWS Ͱ AI αʔϏεΛ࣮૷ɾӡ༻͢ΔͨΊͷ ɹҰൠతͳٕज़৘ใɺ஌ݟɺࣄྫڞ༗ͷ৔ • ͢Ͱʹ׆༻͍ͯ͠Δํ •

    ಋೖΛݕ౼͍ͯ͠Δํ • ԿͦΕ͓͍͍͠ͷʁͳํʢ։࠵͝ͱʹ೉қ౓͕ଟগҧ͍·͢ʣ
  21. ͋Γ͕ͱ͏͍͟͝·ͨ͠ ࢀߟจݙ: • AWS Batch – ؆୯ʹ࢖͑ͯޮ཰తͳόονίϯϐϡʔςΟϯάػೳ – AWS https://aws.amazon.com/jp/batch/

    • AWS Black Belt Online SeminarʮAWS Batchʯͷࢿྉ͓ΑͼQAެ։ http://aws.typepad.com/sajp/2017/02/aws-black-belt-online-seminar-aws- batch.html#QCPzBdn.twitter_tweet_count_m • re:Invent 2016: AWS Big Data & Machine Learning Sessionsɻ https://aws.amazon.com/blogs/big-data/reinvent-2016-aws-big-data- machine-learning-sessions/