반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리


반응형

AI 의 공부법

Linear Regression은 Deep Learning의 Learning 부분을 설명합니다.

Machine 이 스스로 Learning 하도록 만들었다는데 도대체 Machine 은 어떻게 스스로 Learning을 할까요?

똑똑한 AI 의 공부법을 배워 봅시다.

 

https://youtu.be/vBLJi3uYAOI?si=05hXIXtwkpQ9df5Q

 

내 생각에 AI 공부법은 무식하다고 생각합니다.

수천억개에 달하는 파라미터들 마다 하나하나 가중치 값을 바꿔 가면서 더하고 곱하고 미분하고 Softmax로 정규화해서 최선의 답을 찾아가니까요...

 

이번 유투브 강좌 에서는 AI 가 공부하는 방법의 가장 기본이 되는 Deep Learning 의 시작인 Linear Regression 에 대해 알아 봅니다.

 

 

 

 

 

 

 

 

 

반응형


반응형

이전 글에서 GPT 3 API로 초 간단 챕봇을 만들었습니다.

아래 내용이 그 소스 코드 입니다. (자세한 사항은 이전 글을 참조하세요)

https://coronasdk.tistory.com/1257

 

 

GPT-3 API로 초간단 Chatbot 만들기

오늘은 Python 과 ChatGPT API로 간단한 챗봇을 만들어 보겠습니다. import os import openai def open_file(filepath): with open(filepath, 'r', encoding='utf-8') as infile: return infile.read() openai.api_key = open_file('openaiapikey.txt') wh

coronasdk.tistory.com

 

오늘 볼 소스 코드는 아래와 같습니다.

 

이전 소스코드 보다 많이 복잡해 진 것 같지만 별다른 변화는 없고 그냥 26번째 줄 list를 추가했다는 내용밖에 없습니다.

 

우선 1~8번째 줄은 openai api를 사용하기 위해 api key를 제공하는 겁니다. 이전에 다룬 부분이니까 넘어가겠습니다.

 

그다음 10~23번째 줄은 openai.Completion.create() api를 사용하기 위해 만든 함수 입니다.

이전 초간단 챗봇 코드 보다 전달하는 파라미터를 많이 설정했습니다.

이 부분도 이전 글에서 다루었습니다.

 

https://coronasdk.tistory.com/1254

 

OpenAI API 첫 소스코드 분석 (초보자를 위한 해석)

지난번에 OpenAI API 연결을 테스트 하기 위해 만들었던 소스코드를 분석해 보겠습니다. 첫번째 import OpenAI는 OpenAI API 를 사용하기 위해 필요한 겁니다. 이것은 로컬에 OpenAI 를 깔았기 때문에 사용

coronasdk.tistory.com

25번째 줄은 이 파이썬 파일을 실행 했을 경우 그 아래 코드를 실행하라는 의미 입니다.

다른 파이썬 파일을 실행하고 그 파이썬 파일에서 이 파일을 import 한다면 그 아래 내용은 실행되지 않습니다.

그 설명도 윗 글에서 했습니다.

 

그 아래 while 문도 바로 전 글에서 다룬 부분인데 다른 부분은 list()를 추가 했다는 겁니다.

list()를 추가 한 이유는 대화를 할 때 이전 대화와 맥락이 맞는 답변을 받기 위해서 입니다.

 

그러기 위해서는 이전의 질문과 대답을 모두 같이 보내면 됩니다.

그러기 위해서 list를 사용하구요.

 

우선 26번째 줄에서 conversation 이라는 변수를 만들었고 이 변수에는 리스트가 담길 것이라고 선언했습니다.

아래 줄 while True: 는 그냥 아래 내용을 계속 실행하라는 무한 루프이구요.

user_input = input('USER: ') 는 사용자로 부터 입력 받은 내용을 user_input에 담는 겁니다.

이전 소스코드에소 그대로 있습니다. 다른 부분은 아래 라인 입니다.

 

이 user_input을 그대로 prompt로 사용하는 것이 아니라 위에 만들어 놓은 conversation이라는 리스트에 담는 겁니다.

 

conversation.append('USER: %s' % user_input)

 

%s 는 자바에서도 사용하는 것인다. string 형식의 내용이 담길 것이라는 거고 그 string은 ' ' 이 작은 따옴표 밖에 있는 % 에 나오는 내용이 됩니다.

 

그러면 conversation에 user_input 이 담기게 됩니다.

그 다음에 prompt 변수가 나옵니다.

 

여기서는 prompt_chat.txt 라는 파일의 내용을 불러오게 되는데요.

이 파일에는 다름과 같은 내용이 담겨져 있습니다.

이 대화는 USER 와 JAX가 나누는 대화이고 JAX는 세계 평화를 목표로 하는 감성적인 기계이다 라고 상황을 설정해 놓았습니다.

이렇게 상황을 설정하면 GPT 3 는 JAX 의 성격에 맞는 답변을 찾아서 보내 줍니다.

그 아래 <<BLOCK>> 은 의미가 없고 그냥 31번째 줄에서 보여 주듯이 위에서 설정한 text_block을 replace 해주기 위해 만들어 놓은 겁니다.

 

prompt = open_file('prompt_chat.txt').replace('<<BLOCK>>', text_block)

 

이렇게 되면 prompt에는 prompt_chat.txt에 기존에 있는 내용에 text_block을 합한 내용이 저장되게 됩니다.

 

prompt = prompt + '\JAX: '

 

부분은 답변을 표시할 때 그 앞에 JAX: 를 나타내기 위해서 만든 겁니다.

 

그러면 이제 질문이 완성 됐습니다.

 

이 질문을 이용해서 opanai.Completion.create() api를 사용해서 질문을 던지고 답변을 받으면 됩니다.

이 일을 하는 함수는 그 위에 gpt3_completion() 입니다.

 

response = gpt3_completion(prompt)

 

그 함수에 prompt를 던지고 openai로 부터 받는 응답은 response에 담기게 됩니다.

 

그 다음은 그 응답을 print 하는 겁니다.

 

이 대답은 다시 conversation에 추가 됩니다.

 

conversation.append('JAX: %s' % response)

 

이렇게 하면 다음번 질문을 할 때 이전 질문과 대답까지 다 합해서 openai의 GPT3에게 보내서 이전 대화와 맥락이 맞는 답변을 듣게 됩니다.

 

 

이렇게 미리 설정해 놓은 상황과 이전 응답에 맥락이 맞는 대화를 할 수 있는 챗봇을 만들었습니다.

다시 말씀 드리지만 위 응답은 GPT3의 가장 저렴한 테스트 모델인 text-ada-001을 사용했습니다.

비용 절감 차원에서 이 모델로 테스트 하고 있습니다.

text-davinci-003 모델을 사용하면 좀 더 그럴 듯한 대화를 나누실 수 있습니다.

 

전체 소스코드는 아래와 같습니다.

 

import openai

def open_file(filepath) :
    with open(filepath, 'r', encoding='utf-8') as infile :
        return infile.read()
        

openai.api_key=open_file('openaiapikey.txt')

def gpt3_completion(prompt, engine='text-davinci-003', temp=0.7, top_p = 1.0, tokens =400, freq_pen=0.0, pres_pen=0.0, stop=['JAX: ', 'USER: ']) :
    prompt = prompt.encode(encoding='ASCII', errors='ignore').decode()
    response = openai.Completion.create(
        #engine=engine,
        engine='text-ada-001', 
        prompt=prompt,
        temperature=temp,
        max_tokens=tokens,
        top_p=top_p,
        frequency_penalty=freq_pen,
        presence_penalty=pres_pen,
        stop=stop)
    text = response['choices'][0]['text'].strip()
    return text
  
if __name__ == '__main__' :
    conversation = list()
    while True:
        user_input = input('USER: ')
        conversation.append('USER: %s' % user_input)
        text_block = '\n'.join(conversation)
        prompt = open_file('prompt_chat.txt').replace('<<BLOCK>>', text_block)
        prompt = prompt + '\JAX: '
        response = gpt3_completion(prompt)
        print('JAX: ', response)
        conversation.append('JAX: %s' % response)
        

 

반응형

MEGAZONE CLOUD AWS DeepRacer League in Korea

2019. 6. 25. 22:23 | Posted by 솔웅


반응형

메가존 클라우드 AWS Deepracer League가 개최 됩니다.

 

참가 신청은 이곳에서 하실 수 있네요.

 

https://www.megazone.com/deepracer_league_01/ 

 

제1회 메가존 클라우드 AWS DeepRacer 리그 참가 신청

Asia-Pacific & KOREA, No.1 AWS Premier Consulting Partner 메가존 클라우드가 제1회 AWS DeepRacer 대회를 개최 합니다.

www.megazone.com

1등 상금이 100만원에 라스베가스 re:Invent 왕복 항공권 및 숙박권...... 와우....

 

AWS DeepRacer 차량 모델이 있으신 분은 참가하시면 좋겠네요.

(관계자 분이 확인해 주셨는데 DeepRacer 차량이 없어도 된답니다. 관심 있으신 분들은 일단 가셔서 주최측에 있는 차량을 이용해서 참가 하실 수 있답니다.)

 

제가 사는 곳은 조그만 동네라서 차량을 트랙에서 직접 테스트 해 볼 기회를 갖기 무척 힘듭니다.

한국에 계신 분들은 아주 좋은 기회인 듯 합니다.

 

참가하셔서 좋은 결과 있으시길 바랍니다.

 

 

Asia-Pacific & KOREA, No.1 AWS Premier Consulting Partner 메가존 클라우드가 AWS DeepRacer 리그를 개최 합니다.

 

실제 트랙이 설치되어 참가자가 직접 제작한 모델을 실제 차량(Agent)으로 주행 가능하며, 우승 시 상금 외 미국 re:Invent 기간 왕복 항공 및 숙박권이 주어지오니, 많은 신청 부탁 드립니다.

 

  • 대회명 : MEGAZONE CLOLUD Circuit Challenge
  • 대회 일자 : 2019년 7월 4일 (목)
  • 대회 장소 : 신도림 쉐라톤서울 디큐드시티호텔 6층 그랜드볼룸 [약도]
  • 대회 시간 : 오전 10시 ~ 오후 05시
  • 시상
    – 1등 : 상금 100만원 + re:Invent 왕복 항공 및 숙박권
    – 2등 : 상금 50만원
    – 3층 : 상금 30만원
  • 참가 자격 : 직접 제작한 AWS DeepRacer 모델을 보유한 사람

 

메가존 클라우드와 함께 세계 신기록에 도전해 보세요. [세계 기록 보기]

※ 본 리그는 메가존 클라우드가 자체적으로 진행하는 행사로 AWS에서 개최하는 리그와 무관합니다.
※ 상금 및 경품 지급 시 소득세 등 제세공과금이 차감 혹은 청구 됩니다.
※ 본 경기 규칙은 AWS DeepRacer League 규칙을 따르며 트랙 또한 re:Invent 2018 트랙에서 진행 됩니다.

 

========================================

 

저는 AWS Deepracer 모델 차량을 7월 중순에 받을 예정이라서 10월 3일 토론토에서 열리는 경기에 참가할 수 있을 것 같습니다.

 

휴가 내고 비행기 타고 가서 참가할 생각인데.... 

어떻게 될 지 아직...... 

 

지금 제가 만들고 있는 모델은 Kumo Torakku 트랙에서 23초를 기록하고 그 이후에는 전혀 기록이 나아 지질 않고 있습니다.

지금 1,2,3 등은 모두 10초 대 이던데.... 그런 기록은 어떻게 하면 낼 수 있을 지.......

 

3등은 Kimwooglae인걸로 봐서 한국분인것 같네요.

 

 

어떻게 연락해서 방법 좀 배울 수 없을까?

 

혹시 AWS Deepracer 공부하는 커뮤니티 있으면 알려 주세요.

혼자 공부하는 것 보다 서로 경험 공유하면서 배우면 훨씬 좋을 것 같습니다.

 

 

반응형


반응형

Hands-on Exercise 1: Model Training Using AWS DeepRacer Console

 

This is the first of four exercises that you will encounter in this course. This first exercise guides you through building, training, and evaluating your first RL model using the AWS DeepRacer console. To access the instructions for three of these exercises, download and unzip this course package. For this particular exercise, find and open the relevant PDF file and follow the steps within to complete the exercise.

*Note: This exercise is designed to be completed in your AWS account. AWS DeepRacer is part of AWS Free Tier, so you can get started at no cost. For the first month after sign-up, you are offered a monthly free tier of 10 hours of Amazon SageMaker training and 60 simulation units of Amazon RoboMaker (enough to cover 10 hours of training). If you go beyond those free tier limits, you will accrue additional costs. For more information, see the AWS DeepRacer Pricing page.

 

Hands-on Exercise 1- Model Training Using AWS DeepRacer Console.pdf
0.23MB

 

 

 

 

Hands-on Exercise 2- Advanced Model Training Using AWS DeepRacer Console.pdf
0.25MB

 

 

For feedback, suggestions, or corrections, email us at aws-course-feedback@amazon.com.

 

 

Hands-on Exercise 3- Distributed AWS DeepRacer RL Training using Amazon SageMaker and AWS RoboMaker.pdf
0.46MB

 

SageMakerForDeepRacerSetup.yaml
0.01MB

 

AWSTemplateFormatVersion: "2010-09-09"
Description: 'AWS DeepRacer: Driven by Reinforcement Learning'
Parameters:
  SagemakerInstanceType:
    Description: 'Machine Learning instance type that should be used for Sagemaker Notebook'
    Type: String
    AllowedValues:
      - ml.t2.medium
      - ml.t2.large
      - ml.t2.xlarge
      - ml.t3.medium
      - ml.t3.large
      - ml.t3.xlarge
      - ml.m5.xlarge
    Default: ml.t3.medium
  CreateS3Bucket:
    Description: Create and use a bucket created via this template for model storage
    Default: True
    Type: String
    AllowedValues:
      - True
      - False
    ConstraintDescription: Must be defined at True|False.
  VPCCIDR:
    Description: 'CIDR Block for VPC (Do Not Edit)'
    Type: String
    Default: 10.96.0.0/16
  PUBSUBNETA:
    Description: 'Public Subnet A (Do Not Edit)'
    Type: String
    Default: 10.96.6.0/24
  PUBSUBNETB:
    Description: 'Public Subnet B (Do Not Edit)'
    Type: String
    Default: 10.96.7.0/24
  PUBSUBNETC:
    Description: 'Public Subnet C (Do Not Edit)'
    Type: String
    Default: 10.96.8.0/24
  PUBSUBNETD:
    Description: 'Public Subnet D (Do Not Edit)'
    Type: String
    Default: 10.96.9.0/24
  S3PathPrefix:
    Type: String
    Description: 'Bootstrap resources prefix'
    Default: 'awsu-spl-dev/spl-227'
  S3ResourceBucket:
    Type: String
    Description: 'Bootstrap S3 Bucket'
    Default: 'aws-training'
Conditions:
  CreateS3Bucket: !Equals [ !Ref CreateS3Bucket, True ]
  #  NoCreateS3Bucket: !Equals [ !Ref CreateS3Bucket, False ]
Resources:

# Defining the VPC Used for the sanbox ENV, and notebook instance
  VPC:
    Type: 'AWS::EC2::VPC'
    Properties:
      CidrBlock: !Ref VPCCIDR
      EnableDnsSupport: 'true'
      EnableDnsHostnames: 'true'
      Tags:
        - Key: Name
          Value: 'DeepRacer Sandbox'
# There is a few calls made to public to download supporting resources
  InternetGateway:
    Type: 'AWS::EC2::InternetGateway'
    DependsOn: VPC
    Properties:
      Tags:
        - Key: Name
          Value: 'DeepRacer Sandbox IGW'
# Attached this IGW to the sanbox VPC
  AttachGateway:
    Type: 'AWS::EC2::VPCGatewayAttachment'
    DependsOn:
      - VPC
      - InternetGateway
    Properties:
      VpcId: !Ref VPC
      InternetGatewayId: !Ref InternetGateway
# Default setting in the notebook is to use Public IP address to communicate
# between instances running the simulation, and the instances collecting and
# processing. A NatGW could have been used with added costs, but would allow for
# use of private IP address.

# Found in testing that not all ML instance types may not be deployed or avaliable
# in all AZ's within a given region. We are using the newest instance family of T3
  PublicSubnetA:
    Type: 'AWS::EC2::Subnet'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      CidrBlock: !Ref PUBSUBNETA
      AvailabilityZone: !Select
        - '0'
        - !GetAZs ''
      Tags:
        - Key: Name
          Value: 'Deepracer Sandbox - Public Subnet - A'
  PublicSubnetB:
    Type: 'AWS::EC2::Subnet'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      CidrBlock: !Ref PUBSUBNETB
      AvailabilityZone: !Select
        - '1'
        - !GetAZs ''
      Tags:
        - Key: Name
          Value: 'Deepracer Sandbox Public Subnet - B'
  PublicSubnetC:
    Type: 'AWS::EC2::Subnet'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      CidrBlock: !Ref PUBSUBNETC
      AvailabilityZone: !Select
        - '2'
        - !GetAZs ''
      Tags:
        - Key: Name
          Value: 'Deepracer Sandbox Public Subnet - C'
  PublicSubnetD:
    Type: 'AWS::EC2::Subnet'
    DependsOn: VPC
    Properties:
      VpcId: !Ref VPC
      CidrBlock: !Ref PUBSUBNETD
      AvailabilityZone: !Select
        - '3'
        - !GetAZs ''
      Tags:
        - Key: Name
          Value: 'Deepracer Sandbox Public Subnet - D'
# Define the Public Routing Table
  PublicRouteTable:
    Type: 'AWS::EC2::RouteTable'
    DependsOn:
      - VPC
      - AttachGateway
    Properties:
      VpcId: !Ref VPC
      Tags:
        - Key: Name
          Value: 'Deepracer Sandbox Public Routing Table'
# And add in the default route to 0.0.0.0/0
  PublicRouteIGW:
    Type: 'AWS::EC2::Route'
    DependsOn:
      - PublicRouteTable
      - InternetGateway
    Properties:
      RouteTableId: !Ref PublicRouteTable
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId: !Ref InternetGateway
# Attach the routing table to each of the subnets
  PublicRouteTableAssociationA:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    Properties:
      SubnetId: !Ref PublicSubnetA
      RouteTableId: !Ref PublicRouteTable
  PublicRouteTableAssociationB:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    Properties:
      SubnetId: !Ref PublicSubnetB
      RouteTableId: !Ref PublicRouteTable
  PublicRouteTableAssociationC:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    Properties:
      SubnetId: !Ref PublicSubnetC
      RouteTableId: !Ref PublicRouteTable
  PublicRouteTableAssociationD:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    Properties:
      SubnetId: !Ref PublicSubnetD
      RouteTableId: !Ref PublicRouteTable
# Define a S3 endpoint for all the S3 traffic during training
  S3Endpoint:
    Type: AWS::EC2::VPCEndpoint
    Properties:
      VpcId: !Ref VPC
      RouteTableIds:
        - !Ref PublicRouteTable
      ServiceName: !Join
        - ''
        - - com.amazonaws.
          - !Ref 'AWS::Region'
          - .s3
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal: '*'
            Action:
              - 's3:*'
            Resource:
              - '*'
# This exercise is going to need a bucket to store any file generated from training
# There is a conditions to evaluate if the PRAM is true, else this resource would
# not be created.
  SandboxBucket:
    Type: 'AWS::S3::Bucket'
    DeletionPolicy: Retain
    Condition: CreateS3Bucket
    Properties:
      BucketName:
        Fn::Join:
          - "-"
          - - deepracer-trainingexercise
            - Ref: AWS::Region
            - Ref: AWS::AccountId
# Sagemaker is going to be making calls to Robomaker to launch the sim, and
# Sagemaker to launch the training insance. This requries AWS credentals. A
# Principal of sagemaker and robomaker needs to be assiged as both service will
# assuming this role. Default Sagemaker full access and s3 access is needed.
  SageMakerNotebookInstanceRole:
    Type: 'AWS::IAM::Role'
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - sagemaker.amazonaws.com
                - robomaker.amazonaws.com
            Action:
              - 'sts:AssumeRole'
      ManagedPolicyArns:
        - 'arn:aws:iam::aws:policy/AmazonSageMakerFullAccess'
      Path: /
      Policies:
        - PolicyName: DeepRacerPolicy
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action: [ 's3:*',
                          'iam:GetRole' ]
                Resource: '*'
# This is how the notebook gets loaded on to sagemaker. There is a zip file with
# with the needed files, and a second http call to pull down the notebook.
# This is only done "OnCreate" - when the sagemaker instance is first deployed
# You can can the script get run "OnStart" (when a sagemaker instance changes
# from a stopped state to a running state). This would automaticlly update file
# to be the latest form source, but could over write changes applied during
# your testing
  SageMakerNotebookInstanceLifecycleConfig:
    Type: 'AWS::SageMaker::NotebookInstanceLifecycleConfig'
    Properties:
  #    OnStart:
  #      - Content:
  #          Fn::Base64:
  #            #!/bin/bash
  #            !Sub |
  #            cd SageMaker
  #            chown ec2-user:ec2-user -R /home/ec2-user/SageMaker

      OnCreate:
        - Content:
            Fn::Base64:
              !Sub |
              cd SageMaker
              curl -O https://us-west-2-${S3ResourceBucket}.s3.amazonaws.com/${S3PathPrefix}/scripts/rl_deepracer_robomaker_coach.ipynb
              curl -O https://us-west-2-${S3ResourceBucket}.s3.amazonaws.com/${S3PathPrefix}/scripts/rl_deepracer_robomaker_coach.zip
              unzip rl_deepracer_robomaker_coach.zip
              chown ec2-user:ec2-user -R /home/ec2-user/SageMaker
# Security Group for sagemaker instance running in this VPC
  SagemakerInstanceSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Sagemaker Security Group
      VpcId: !Ref VPC
      SecurityGroupIngress:
      - IpProtocol: tcp
        FromPort: 1
        ToPort: 65535
        CidrIp: !Ref VPCCIDR
      - IpProtocol: udp
        FromPort: 1
        ToPort: 65535
        CidrIp: !Ref VPCCIDR
      SecurityGroupEgress:
      - IpProtocol: tcp
        FromPort: 1
        ToPort: 65535
        CidrIp: !Ref VPCCIDR
      - IpProtocol: udp
        FromPort: 1
        ToPort: 65535
        CidrIp: !Ref VPCCIDR
# Creating the Sagemaker Notebook Instance
  SageMakerNotebookInstance:
    Type: 'AWS::SageMaker::NotebookInstance'
    Properties:
      #NotebookInstanceName: 'DeepracerSagemakerSandbox'
      NotebookInstanceName: !Join ["-", ["DeepRacerSagemakerSandbox", !Ref "AWS::StackName"]]
      SecurityGroupIds:
        - !GetAtt
          - SagemakerInstanceSecurityGroup
          - GroupId
      InstanceType: !Ref SagemakerInstanceType
      SubnetId: !Ref PublicSubnetA
      Tags:
        - Key: Name
          Value: 'DeepRacer Sandbox'
      LifecycleConfigName: !GetAtt
          - SageMakerNotebookInstanceLifecycleConfig
          - NotebookInstanceLifecycleConfigName
      RoleArn: !GetAtt
          - SageMakerNotebookInstanceRole
          - Arn
Outputs:
  # Display the name of the bucekt that was created from this CFN Stack
    ModelBucket:
      Condition: CreateS3Bucket
      Value: !Ref SandboxBucket
  # URL to get to the Sagemaker UI, and find the Jupyter button. 
    SagemakerNotebook:
      Value:
        !Sub |
          https://console.aws.amazon.com/sagemaker/home?region=${AWS::Region}#/notebook-instances/${SageMakerNotebookInstance.NotebookInstanceName}

반응형


반응형

Introduction to reinforcement learning

 

Developers, start your engines!

This guide will walk you through the basics of reinforcement learning (RL), how to train an RL model, and define the reward functions with parameters.

With this knowledge, you’ll be ready to race in the 2019 AWS DeepRacer League.

 

 

https://d2k9g1efyej86q.cloudfront.net/

 

Introduction to Reinforcement Learning

 

d2k9g1efyej86q.cloudfront.net

 

(RL)Reinforcement learning (RL)은 기계 학습 machine learning의 한 유형으로, agent가 원하는 임무를 어떻게 수행할 것인가를 배우기 위해 주어진 환경environment 을 탐구하는 것입니다. 좋은 결과를 위한 액션을 취하고 나쁜 결과를 초래하는 액션은 회피함으로서 원하는 임무에 최적화 된 행동을 학습하게 됩니다.  

reinforcement learning 모델은 경험을 통해 배우며 시간이 지남에 따라 어떤 행동이 최상의 보상reward으로 이어질지 식별 할 수 있게 됩니다.

 

다른 타입의 machine learning

 

Supervised learning

예제 중심 교육 - 주어진 입력들에 대해 알려진 출력들에 대한 레이블된 데이터를 가지고 이 모델은 새로운 입력에 대한 출력을 예측하도록 훈련됩니다. 

 

Unsupervised learning

추론 기반 교육 - 알려진 출력이 없는 레이블된 데이터를 가지고 이  모델은 입력 데이터 내의 관련 구조 또는 유사한 패턴을 식별하도록 훈련됩니다.

 

How does AWS DeepRacer learn to drive by itself?

 

In reinforcement learning, an agent interacts with an environment with an objective to maximize its total reward.

The agent takes an action based on the environment state and the environment returns the reward and the next state. The agent learns from trial and error, initially taking random actions and over time identifying the actions that lead to long-term rewards.

Let's explore these ideas and how they relate to AWS DeepRacer.

 

reinforcement learning에서 agent 는 환경environment 과 상호 작용하여 총 보상reward을 최대화합니다.

agent 는 환경environment  상태state 에 따라 조치를 취하고 환경environment  은 보상reward과 다음 상태state 를 반환합니다. 에이전트agent 는 초기에 무작위로 행동을 취하고 시간이 지남에 따라 장기 보상long-term rewards으로 이어지는 행동을 식별함으로써 이러한 시행 착오를 통해 학습합니다.

이런 각각의 개념들을 살펴보고 AWS DeepRacer와의 관계에 대해서도 알아보겠습니다.

Agent

The agent simulates the AWS DeepRacer vehicle in the simulation for training. More specifically, it embodies the neural network that controls the vehicle, taking inputs and deciding actions.

 

에이전트agent 는 훈련을 하기 위해 시뮬레이션에서 AWS DeepRacer 차량을 시뮬레이트 합니다. 보다 구체적으로, 차량을 제어하고 입력을 취하고 행동을 결정하는 신경망을 구현합니다.

 

Environment

The environment contains a track that defines where the agent can go and what state it can be in. The agent explores the envrionment to collect data to train the underlying neural network.

 

환경environment 은 에이전트agent 가 어디로 갈 수 있고 어떤 상태에 놓일 수 있는 지에 대해 정의하는 트랙으로 구성됩니다.  에이전트는 기본 신경 네트워크를 훈련하기 위해 주어진 환경(트랙)을 탐색하면서 데이터를 수집합니다.

 

State

A state represents a snapshot of the environment the agent is in at a point in time.

For AWS DeepRacer, a state is an image captured by the front-facing camera on the vehicle.

 

상태state 는 특정 시점에 에이전트가있는 환경의 스냅 샷을 가리킵니다.
AWS DeepRacer의 경우 상태는 차량의 전면 카메라가 캡처 한 이미지입니다.

 

Action

An action is a move made by the agent in the current state. For AWS DeepRacer, an action corresponds to a move at a particular speed and steering angle.

 

동작action 은 현재 상태에서 agent가 수행 한 동작입니다. AWS DeepRacer의 경우 동작은 특정 속도 및 방향(핸들) 각도 등의 움직임과 관계된 액션을 말합니다. 

 

Reward

The reward is the score given as feedback to the agent when it takes an action in a given state.

In training the AWS DeepRacer model, the reward is returned by a reward function. In general, you define or supply a reward function to specify what is desirable or undesirable action for the agent to take in a given state.

 

보상reward은 어떤 주어진 상태에서 action를 취했을 때 agent 에게 피드백으로 주어지는 점수입니다.

AWS DeepRacer 모델을 교육 할 때 보상reward reward function에 의해 반환됩니다. 일반적으로 agent 가 주어진 상태에서 취할 수있는 바람직하거나 바람직하지 않은 작업을 지정하기 위해 보상 기능을 정의하거나 제공합니다.

 

 

 

훈련은 반복적 인 과정입니다. 시뮬레이터에서 에이전트는 환경을 탐색하고 경험을 쌓습니다. 수집 된 경험은 신경망을 주기적으로 업데이트하는 데 사용되며 업데이트 된 모델은 더 많은 경험을 생성하는 데 사용됩니다.

 

AWS DeepRacer를 사용하여 자율 운전을 위한 차량을 교육합니다. 교육 과정을 시각화하는 것이 까다로울 수 있으므로 간단한 예를 살펴 보겠습니다.

 

 

이 예에서는 출발점에서 결승점까지 차량이 최단 경로로 갈 수 있도록 훈련시키려고 합니다.

 

우리는 환경environment 을 사각형 격자로 단순화했습니다. 각 사각형은 개별 상태를 나타내며, 목표 방향으로 차량을 위 또는 아래로 움직일 수 있습니다.

 

 

grid 내의 각 격자(사각형)마다 점수를 할당 할 수 있습니다. 그럼으로서 어떤 행동에 인센티브를 줄지 결정할 수 있게 됩니다. 

 

여기서 우리는 트랙의 가장자리에있는 사각형들을 "정지 상태 stop states"로 지정하여 차량이 트랙에서 벗어 났음을 알립니다.

 

우리가 트랙의 중심을 주행하는 법을 배울 수 있게 하도록 차량에 인센티브를 부여하기를 원하기 때문에 센터 라인의 사각형에 높은 보상reward 을 설정하고 다른 곳에는 보다 낮은 보상reward 을 설정합니다.

 

An episode

In reinforcement training, the vehicle will start by exploring the grid until it moves out of bounds or reaches the destination.

 

As it drives around, the vehicle accumulates rewards from the scores we defined. This process is called an episode.

In this episode, the vehicle accumulates a total reward of 2.2 before reaching a stop state.

 

reinforcement training은 여기서 차량이 grid 를 탐색하기 시작하여 경계를 벗어나거나 목적지까지 도달하면 일단락 하게 됩니다.

 

차량이 움직이게 되면 우리가 지정한 점수에 따라 rewards 가 점점 쌓이게 됩니다. 이러한 과정을 에피소드라고 합니다. 위 에피소드에서 이 차량이 stop state에 도달하기 까지 총 2.2 점의 reward 를 쌓았습니다.  

 

Iteration

Reinforcement learning algorithms are trained by repeated optimization of cumulative rewards.

 

Reinforcement learning algorithms은 누적된 rewards를 최적화 (최대화) 하기 위해 반복해서 훈련하게 됩니다.

 

The model will learn which action (and then subsequent actions) will result in the highest cumulative reward on the way to the goal.

 

이 모델은 우리가 목표로 하는 것을 달성하기 위한 최대화된 누적보상의 결과를 가져 올 수 있게 하는 것이 어떤 행동 (그리고 후속 행동)인가를 배우게 됩니다. 

 

Learning doesn’t just happen on the first go; it takes some iteration. First, the agent needs to explore and see where it can get the highest rewards, before it can exploit that knowledge.

 

학습은 한번에 완성되지 않습니다. 반복이 필요합니다. 첫째, 에이전트는 knowledge를 취하기 전에 가장 높은 보상을 받을 수 있는 것이 어떤 것인지를 탐색해야 합니다. 

 

Exploration

As the agent gains more and more experience, it learns to stay on the central squares to get higher rewards.

If we plot the total reward from each episode, we can see how the model performs and improves over time.

 

agent 는 점점 더 많은 경험을 쌓게 됩니다. 그러는 와중에 더 많은 점수를 얻으려면 중앙 격자를 계속 따라가야 한다는 것을 배우게 될 것입니다. 

 

각 에피소드별 보상 점수가 어떤지를 보면 이 모델이 어떤 퍼포먼스를 보여주고 있고 얼마나 개선되고 있는지를 알 수 있습니다.

Exploitation and Convergence

With more experience, the agent gets better and eventually is able to reach the destination reliably.

 

경험이 많아질 수록 agent 는 점점 더 나아지고 결국에는 목표에 도달할 수 있게 됩니다.

 

Depending on the exploration-exploitation strategy, the vehicle may still have a small probability of taking random actions to explore the environment.

 

이 exploration-exploitation strategy(탐사-탐사 전략)에 근거해서 차량은 환경을 탐사하기 위한 랜덤한 액션 (무작위 행동)을 할 가능성이 점점 더 줄어들게 됩니다.

 

 

 

AWS DeepRacer에서 보상 기능 reward function은 현재 상태를 설명하고 숫자 보상 값을 반환하는 특정 매개 변수가있는 Python 함수입니다.

 

보상 기능으로 전달 된 매개 변수는 트랙의 위치와 방향, 관측 된 속도, 조향 각도 등과 같은 차량 상태의 다양한 측면을 나타냅니다.

 

우리는이 매개 변수 중 몇 가지를 탐색하고 트랙 주변을 따라 차량을 묘사하는 방법을 살펴 보겠습니다.

 

  • Position on track
  • Heading
  • Waypoints
  • Track width
  • Distance from center line
  • All wheels on track
  • Speed
  • Steering angle

1. Position on track

The parameters x and y describe the position of the vehicle in meters, measured from the lower-left corner of the environment.

 

매개 변수 x 및 y는 환경의 왼쪽 하단 모서리에서 측정 한 차량의 위치를 미터 단위로 나타냅니다.

 

 

2. Heading

The heading parameter describes the orientation of the vehicle in degrees, measured counter-clockwise from the X-axis of the coordinate system.

 

heading 매개 변수는 좌표계의 X 축에서 시계 반대 방향으로 측정 한 차량의 방향을 도 단위로 나타냅니다.

 

 

3. Waypoints

The waypoints parameter is an ordered list of milestones placed along the track center.

Each waypoint in waypoints is a pair [x, y] of coordinates in meters, measured in the same coordinate system as the car's position.

 

waypoints 매개 변수는 트랙 센터를 따라 배치 된 마일스톤의 정렬 된 목록입니다.
waypoints 안에있는 각 waypoints 는  자동차의 위치에 대해 좌표계에서 측정 된 미터 단위의 좌표 [x, y] 쌍입니다.

 

 

4. Track width

The track_width parameter is the width of the track in meters.

 

track_width parameter는 미터로 된 트랙의 너비 입니다.

 

 

5. Distance from center line

The distance_from_center parameter measures the displacement of the vehicle from the center of the track.

The is_left_of_center parameter is a boolean describing whether the vehicle is to the left of the center line of the track.

 

distance_from_center 매개 변수는 트랙의 중심에서 차량의 변위를 측정합니다.
is_left_of_center 매개 변수는 차량이 트랙의 중심선 왼쪽에 있는지 여부를 나타내는 boolean  값입니다.

 

 

6. All wheels on track

The all_wheels_on_track parameter is a boolean (true / false) which is true if all four wheels of the vehicle are inside the track borders, and false if any wheel is outside the track.

 

all_wheels_on_track 매개 변수는 boolean  (true / false)이며 차량의 네 바퀴가 모두 트랙 테두리 안에 있으면 true이고, 하나라도 바퀴가 밖에 있으면 false가 됩니다.

 

 

7. Speed

The speed parameter measures the observed speed of the vehicle, measured in meters per second.

 

speed parameter는 초속 몇미터인가를 나타내는 차량의 관측된 속도입니다.

 

 

8. Steering angle

The steering_angle parameter measures the steering angle of the vehicle, measured in degrees.

This value is negative if the vehicle is steering right, and positive if the vehicle is steering left.

 

steering_angle 매개 변수는 차량의 조향 각도를 도 단위로 측정합니다.
이 값은 차량이 오른쪽으로 조향하는 경우 음수이고 차량이 좌회전하는 경우 양수입니다.

 

 

read the detailed documentation

 

Train and Evaluate AWS DeepRacer Models Using the AWS DeepRacer Console - AWS DeepRacer

Train and Evaluate AWS DeepRacer Models Using the AWS DeepRacer Console To train a reinforcement learning model, you can use the AWS DeepRacer console. In the console, create a training job, choose a supported framework and an available algorithm, add a re

docs.aws.amazon.com

 

 

The Reward Function.

 

Putting it all together

With all these parameters at your disposal, you can define a reward function to incentivize whatever driving behavior you like.

Let's see a few examples of reward functions and how they use the parameters to determine a reward. The following three reward functions are available as examples in the AWS DeepRacer console so you can try them out and see how they behave, or submit them to the AWS DeepRacer League.

 

이러한 모든 매개 변수를 마음대로 활용하면 원하는 운전 행동에 대한 인센티브를 주는 보상 기능을 정의 할 수 있습니다.

보상 기능의 몇 가지 예와 보상을 결정하기 위해 매개 변수를 사용하는 방법을 살펴 보겠습니다. AWS DeepRacer 콘솔에서 다음과 같은 세 가지 보상 기능을 사용할 수 있으므로 이를 시험해보고 어떻게 동작하는지 보거나 AWS DeepRacer League에 제출할 수 있습니다.

 

 

이 예에서는 자동차가 궤도에 머무를 때 높은 보상을주고 차가 궤도 경계를 벗어나는 경우 페널티를줍니다.

이 예제에서는 all_wheels_on_track, distance_from_center 및 track_width 매개 변수를 사용하여 자동차가 트랙에 있는지 여부를 확인하고 높은 경우 보상을 제공합니다.

이 기능은 트랙에 머무르는 것 이외의 특정 종류의 행동에 대해 보상하지 않으므로이 기능으로 교육받은 agent 는 특정 행동으로 수렴하는 데 시간이 오래 걸릴 수 있습니다.

 

 

 

 

이 예제에서 우리는 트랙의 중심에서 차가 얼마나 떨어져 있는지 측정하고, 차가 중심선에 가까이 있으면 더 높은 보상을줍니다.

이 예제에서는 track_width 및 distance_from_center 매개 변수를 사용하고 트랙의 중심에서 차가 멀어 질수록 보상이 줄어 듭니다.

이 예는 보상의 대상이되는 운전 행동의 유형에 따라 다르므로이 기능을 사용하여 교육을받은 agent는 트랙을 잘 따라갈 수 있습니다. 그러나 모서리의 가속이나 제동과 같은 다른 행동을 배우기는 쉽지 않습니다.

 

 

 

대안의 전략 alternative strategy은 자동차가 운전하는 방식에 관계없이 각 단계에 대해 지속적인 보상을 제공하는 것입니다.

이 예제는 입력 매개 변수를 사용하지 않고 각 단계마다 상수 보상 1.0을 반환합니다.

에이전트의 유일한 인센티브는 트랙을 성공적으로 끝내는 것이고, 더 빠르게 운전하거나 특정 경로를 따라갈 인센티브가 없습니다. 그것은 불규칙하게 행동 할 수 있습니다.

그러나 보상 기능은 agent의 행동을 제한하지 않으므로 예상치 못한 전략과 행동을 탐색하여 오히려 실적이 좋을 수도 있습니다.

 

 

 

 

 

 

반응형

What Is AWS DeepRacer?

2018. 12. 24. 02:18 | Posted by 솔웅


반응형


AWS DeepRacer consists of the following components:


AWS DeepRacer는 다음과 같은 콤포넌트들로 구성돼 있다.


  • An AWS Machine Learning service to train and evaluate reinforcement learning models.

  • 강화 학습 모델들을 훈련하고 평가하기 위한 AWS Machine Learning service

  • AWS DeepRacer scale model vehicles that can drive themselves by running inference on a trained reinforcement learning model.

  • AWS DeepRacer scale model 차량은 훈련된 reinforcement learning model 을 기반한 추론을 실행함으로서 스스로 운전할 수 있음

  • AWS DeepRacer Racing Leagues for the participants to learn from and inspire each other through competitions on model performances.

  • AWS DeepRacer Racing Leagues는 참가자들이 DeepRacer 운행관련 경쟁을 통해 서로 배우고 영감을 주고받는 기회를 제공함



It provides you with an interactive learning platform for users of all levels to learnreinforcement learning and to prototype autonomous driving applications.

이를 통해 모든 사용자가 reinforcement learning을 배우고 자율 주행 어플리케이션의 기본 틀을 만들 수 있는 상호 작용하는 learning platform을 여러분에게 제공하게 됩니다.


With a cloud-based simulator and an AWS DeepRacer model vehicle, AWS DeepRacer lets you train, evaluate, and experiment with reinforcement learning models for autonomous racing in a virtual or physical environment.


클라우드 기반 시뮬레이터와 AWS DeepRacer model 차량을 가지고 여러분이 가상 혹은 실제 환경에서 자율 주행 레이싱을 하도록 reinforcement learning models을 이용해 훈련하고 평가하고 실험할 수 있도록  AWS DeepRacer는 그 기회를 제공합니다.



Topics



The AWS DeepRacer Console





The AWS DeepRacer console is a graphical user interface to interact with the AWS DeepRacer service. You can use the console to train a reinforcement learning model, to evaluate the model performance in simulation as rendered by the AWS RoboMaker simulator.

AWS DeepRacer console은  AWS DeepRacer service와 상호 작용하는 graphical user interface 입니다. 이 콘솔을 사용하여 AWS RoboMaker 시뮬레이터에서 렌더링 한 시뮬 레이션에서 모델 성능을 평가하는 강화 학습 모델을 학습 할 수 있습니다.


In summary, the AWS DeepRacer console supports the following features:

요약하면 AWS DeepRacer 콘솔은 다음 기능을 지원합니다.

  • The AWS DeepRacer console lets you create a training job to train a reinforcement learning model, with a specified reward function, optimization algorithm, environment, and hyperparameters.

  • AWS DeepRacer console을 사용하면 reinforcement learning model 트레이닝을 위한 훈련작업을 만들 수 있습니다. 이 작업은 특정 보상기능, 최적화된 알고리즘, 환경 그리고 hyperparameters 등을 사용해서 이루어 질 수 있습니다.

  • The AWS DeepRacer console provides a simulated track for you to train and evaluate a model on a selected track.

  • AWS DeepRacer console은 훈련하기 위한 시뮬레이트 된 트랙과 해당 트랙에서의 모델 평가 등을 제공합니다.

  • The AWS DeepRacer console lets you clone a trained model to retrain it by tuning hyperparameters to optimize your model's performance.

  • AWS DeepRacer console을 사용하면 hyperparameters를 튜닝함으로서 훈련 모델을 복제해 해당 모델의 성능을 최적화 할 수 있습니다.



AWS DeepRacer Vehicles as Physical Agents


The AWS DeepRacer vehicle is a scaled-down physical vehicle that can drive itself on a real track using a deployed reinforcement learning model.

AWS DeepRacer 차량은 deploy된 reinforcement learning model을 하용해 실제 트랙에서 차량을 드라이브 할 수 있는 실제 차량의 축소본입니다.

  • You can manually control the vehicle, or turn the autonomous mode that requires a deployed model.

  • 여러분은 직접 수동으로 차량을 컨트롤 할 수 있으며 자율 모드를 켜 필요한 deployed model을 이용할 수도 있습니다.

  • The autonomous mode runs inference on the vehicle's compute module, aided with images from the camera.

  • 자율 모드는 차량의 compute module에서 inference(추론)을 실행하게 되며 이 과정에서 카메라를 통해 얻은 이미지를 활용하게 됩니다.


The AWS DeepRacer League






The AWS DeepRacer League is an important component of AWS DeepRacer. It is intended to foster communal learning and collaborative exploration through sharing and competitions.


AWS DeepRacer 리그는  AWS DeepRacer의 중요한 구성 요소입니다. 공유 및 경쟁을 통해 공동 학습 및 공동 탐사를 촉진하기위한 것입니다.



Learning with a group of like-minded developers can be rewarding because group members can share insights and learn from each other. Competitions can serve as powerful motivations for participants to inspire each other. AWS DeepRacer then ranks the performance for the users to discover the good, better, and best models of the group.


이 분야에 흥미를 가지고 있는 개발자들과 함께 배운다는 것은 매우 도움이 됩니다. 왜냐하면 서로 서로 자기가 이해한 것과 배운것들을 나눌 수 있기 때문이죠. 이 리그 참가자들은 경쟁을 통해 서로에게 강력한 모티베이션을 받을 수 있습니다. AWS DeepRacer는 참가자들의 퍼포먼스를 보고 그 그룹의 최고 수상자와 대상 우수상등을 평가하게 됩니다.



AWS DeepRacer As an End-to-End Learning Platform





Reinforcement learning, especially deep reinforcement learning, has proven effective in solving a wide array of autonomous decision-making problems. It has applications in financial trading, data center cooling, fleet logistics, and autonomous racing, to name a few.

Reinforcement learning 특히 심층 Reinforcement learning은 광범위한 자율적 의사결정 문제를 해결하는데 아주 효과적임이 입증 되었습니다. 금융 거래, 데이터 센터 냉각(온도 관리) 그리고 자율 주행 경주 분야에 이를 이용한 어플리케이션들이 있습니다.



As someone new to reinforcement learning, you might be intrigued by it's potential to solve real-world problems. You might like to acquire the necessary skills to tackle challenges in your business or application domain. However, reinforcement learning has a steep learning curve due to extensive technological scope and depth the field depends on. Real-world experimentation requires constructing a physical agent (e.g., an autonomous racing car). It also requires that you secure a physical environment (e.g., a driving track or public road), which can be costly, hazardous, and time-consuming. The requirements go beyond merely understanding reinforcement learning.

reinforcement learning에 대해 잘 모르시는 분들이 있다면 여러분은 아마 곧 이 방법론이 실제 세상의 여러가지 문제들을 해결할 수 있는 그 잠재력이 있다는 것에 대해 알게 되고 흥미를 가지게 될 것입니다. 여러분의 사업이나 application domain에 있는 문제들을 해결하는데 필요한 기술들을 얻으실 수 있을 겁니다.  reinforcement learning은 광범위한 기술 범위와 해당 분야의 깊이의 특성으로 인해 가파른 학습 곡선을 갖습니다. 실제 세상에서의 실험은 물리적인 시설이 요구 됩니다. (예: 자율 주행 레이싱 자동차 등). 또한 준비하기에 비싸고, 위험하고 시간 소모적일 수 있는 물리적인 환경도 확보해야 합니다. (예: 운전 트랙, 공공 도로 등) 단순히 reinforcement learning에 대해 이해하는 것 만으로 충족되지 않는 그 이상의 요구되는 조건들이 있다는 것입니다.



To help lower the learning curve, AWS DeepRacer simplifies the process in three ways:

배움의 기복을 줄이기 위해 AWS DeepRacer는 다음과 같은 세가지 방법으로 프로세스를 단순화 합니다.


  • By offering a wizard to guide training and evaluating reinforcement learning models pre-defined environments including states, actions and customizable reward functions.

  • 사전 정의된 상태, 동작 그리고 사용자 정의 가능한 보상기능 등을 포함한 환경이 있는 reinforcement learning models을 가지고 wizard를 통해 훈련과 평가 등을 가이드 하는 기능을 제공합니다.

  • By providing a simulator to emulate interactions between a virtual agent and a virtual environment.

  • 가상 에이전트와 가상 환경 사이의 상호 작용들을 에뮬레이트 하기 위한 시뮬레이터를 제공합니다.

  • By offering an AWS DeepRacer vehicle as a physical agent for evaluation of a trained model in a physical environment. This closely resembles a real-world use case.

  • 실제 물리적인 AWS DeepRacer 자동차를 제공해 실제 물리적 환경에서 훈련된 모델을 평가 할 수 있도록 합니다. 이는 실제 세상에서의 use case와 유사한 상황과 결과를 제공할 겁니다.


At a high level, using AWS DeepRacer to develop reinforcement learning skills and to explore its application goes as follows:


대략적으로 AWS DeepRacer를 사용해서 reinforcement learning 기술을 개발하고 실제 응용프로그램을 개발하고 배우는 과정은 다음과 같습니다.


  1. Create and train a reinforcement learning model using a wizard on the AWS DeepRacer console.

    AWS DeepRacer 콘솔에서 wizard를 사용해 reinforcement learning model을 생성하고 훈련합니다.

  2. Evaluate the trained model on a chosen track to observe how it performs and to determine how to tune the model.

    트랙을 선택해서 훈련된 모델을 평가하여 그 모델이 어떻게 작동하고 어떻게 개선되어야 하는지를 알수 있도록 합니다.

  3. Deploy the trained model to an AWS DeepRacer vehicle. Let the vehicle drive itself on a track that is built according to AWS DeepRacer track specifications for a physical experience.

    해당 훈련된 모델을 AWS DeepRacer 차량에 Deploy 합니다. 그 차량이 해당 트랙에서 스스로 드라이브 하도록 합니다. 이 트랙은 실제 물리적 환경에서의 실험을 위해 AWS DeepRacer에서 지정한 스펙에 맞도록 만들어 진 트랙 입니다.









AWS DeepRacer Basic Concepts and Terminology


AWS DeepRacer builds on the following concepts and uses the following terminology.

AWS DeepRacer

Also referred to as AWS DeepRacer vehicle. One type of AWS DeepRacer vehicle is an AWS DeepRacer car that is a 1:18-scale model car. It has a mounted camera and an on-board compute module. The module can run inference against a deployed reinforcement learning model in order to drive itself along a track. The compute module and the vehicle chassis are powered by dedicated batteries known as the compute battery and the drive battery, respectively.

AWS DeepRacer vehicle이라고도 합니다. 이는 실제 차량의 1/18로 축소된 AWS DeepRacer 차량입니다. 이 차량에는 카메라와 compute module이 장착돼 있습니다. 이 모듈은 이 차량에 deploy된 트랙에서 스스로 드라이브할 수 있도록 미리 훈련된 reinforcement learning model과 작동하여 inference(추론)를 하게 됩니다. compute module과 차량 새새들은 compute battery라고 알려진 전용 배터리와 driver 배터리를 통해 전원이 공급되게 됩니다.


AWS DeepRacer service

An AWS Machine Learning service for learning and exploring reinforcement learning with applications focused on autonomous racing. The AWS DeepRacer service supports the following features:

AWS 머쉰 러닝은 자율 주행에 촛점을 맞춘 어플리케이션으로 reinforcement learning을 배우고 탐구하기 위한 서비스 입니다. AWS DeepRacer service는 다음과 같은 기능을 지원합니다.

  1. Training a reinforcement learning model on the cloud.

    클라우드상에서의 reinforcement learning model 훈련하기

  2. Evaluating the trained model in the AWS DeepRacer console.

    AWS DeepRacer 콘솔에서 훈련된 모델을 평가하기

  3. Download the trained model artifacts to an AWS DeepRacer vehicle.

     AWS DeepRacer 차량에 훈뎐된 모델 artifacts 다운로드하기



Reinforcement learning

A machine learning method that is focused on autonomous decision making by an agent to achieve specified goals through interactions with an environment. In reinforcement learning, learning is achieved through trial and error and training does not require labeled input, but relies on the reward hypothesis. The hypothesis stipulates that all goals can be achieved by maximizing the expected future reward over all action sequences. In reinforcement learning, designing the reward function is critical. The better crafted reward function, the better the agent can decide what actions to take to reach the goal.

For autonomous racing, the agent is a vehicle. The environment includes traveling routes and traffic conditions. The goal is for the vehicle to reach its destination in a timely manner without accidents. Rewards are scores used to encourage safe and speedy travel to the destination. The scores penalize dangerous and wasteful driving.


machine learning 방법론으로 자율적인 의사결정에 촛점을 맞춘 기계학습 방법입니다. 이는 어떤 환경과 상호 작용함을 통해 지정된 목표를 달성하기 위한 에이전트에 의해 수행됩니다.
reinforcement learning에서 learning은 어떠한 input을 필요로하지 않고 reward hypothesis에 의해 시도하고 실패하는 과정을 통해 획득되어 집니다.
hypothesis(가설)은 모든 action sequences를 통해 기대되는 미래의 보상을 극대화 함으로서 목표를 달성할 수 있다고 규정하고 있다. 좀 더 나은 보상 기능 (reward function)과 좀 더 나은 에이전트는 그 목표를 달성하기 위한 액션들을 결정할 수 있다. 자율 주행에서 에이전트는 차량이 된다. 환경은 주행하는 루트(트랙)과 traffic(교통) conditions이 포함된다. 그 차량의 목표는 사고 없이 최단시간에 목적지에 도달하는 것이다. 보상 (Rewards)는 목적지까지 안전하고 빨리 주행하도록 하는 점수 이다. 이 점수는 위험하고 시간낭비적인 주행에 대해서는 페널티를 줍니다.



To encourage learning during the training process, the reinforcement learning agent must be allowed to pursue individual actions that might not result in higher rewards from time to time. This practice is referred to as the exploration and exploitation trade-off. It helps reduce or remove the likelihood that the agent might be misguided into spurious destinations.


훈련 과정에서 해당 학습을 장려하기 위해 reinforcement learning은 수시로 좀 더 높은 보상을 얻을 수 없는 개별적인 액션들에 대해 멈출 수 있도록 하는 기능이 반드시 허용되어야 합니다. 이러한 practice는 탐구와 착취 (exploitation)의 거래라고 합니다. 이 방법은 에이전트가 잘못된 가이드로 인해 잘못된 목적지에 도달할 가능성을 줄이거나 제거하는데 도움이 됩니다.


For a more formal definition, see reinforcement learning on Wikipedia.


Reinforcement learning model

The environment prescribes the states it has, the actions that can be taken by the agent and the rewards that will be received by taking these actions. The strategy with which the agent decides its action is referred to as a policy. Hence the policy takes the environment state as input and outputs the action to take. In deep reinforcement learning, the policy is often represented by a deep neural network, and we refer to this as the reinforcement learning model. It is used to run inference both in simulation and in the AWS DeepRacer model vehicle to power autonomous racing. Each training job generates one model. A model can be generated even if the training job is terminated early. A model is immutable, which means it cannot be modified and overwritten after it's created.

환경은 에이전트가 취할 수있는 조치와 이러한 조치를 취함으로써 수령 할 보상을 규정합니다. 에이전트가 조치를 결정하는 전략을 정책이라고합니다. 따라서 정책은 환경 상태를 입력으로 취하여 취할 조치를 출력합니다. 심층 강화 학습에서는 정책이 심층 신경 네트워크로 대표되는 경우가 많으며 이를 보강 학습 모델이라고합니다. 시뮬레이션 및 AWS DeepRacer 모델 차량에서 추측을 실행하여 자율적 인 경주에 힘을 실어주는 데 사용됩니다. 각 교육 작업은 하나의 모델을 생성합니다. 훈련 작업이 조기에 종료 되더라도 모델을 생성 할 수 있습니다. 모델은 변경 불가능합니다. 즉, 모델을 수정 한 후에는 덮어 쓸 수 없습니다.







Training job

A training job is a workload that trains a reinforcement learning model and outputs the trained model artifacts to run inference on. Each training job produces one and only one model. The AWS DeepRacer console creates a training job for you when you create and train a model. For each job, you can do the following:

교육 작업은 보강 학습 모델을 훈련하고 유추 된 실행을 위해 훈련 된 모델 아티팩트를 출력하는 워크로드입니다. 각 교육 과정은 하나의 모델 만 생성합니다. AWS DeepRacer 콘솔은 모델을 생성하고 훈련 할 때 교육용 작업을 생성합니다. 각 작업에 대해 다음을 수행 할 수 있습니다.

  • View the training progress while the job is running.

  • View the training summary after the job is done.

  • Terminate a training job in progress at any time.

  • 작업이 진행되는 동안 교육 과정을 봅니다.
    작업이 완료된 후 교육 요약을 봅니다.
    진행중인 교육 일을 언제든지 종료합니다.


Evaluation job

An evaluation job is a workload that tests the performance of a model measured by given metrics after the training job is done. With AWS DeepRacer, the standard performance metric is the driving time an agent takes to complete a lap in a track and an additional metric is the percentage of the lap completed. To evaluate a trained model in AWS DeepRacer, you can do the following:


평가 작업은 교육 작업이 완료된 후 주어진 측정 항목으로 측정 된 모델의 성능을 테스트하는 workload입니다. AWS DeepRacer의 표준 성능 메트릭은 에이전트가 트랙에서 랩을 완료하는 데 걸리는 주행 시간이며 추가 메트릭은 완료된 랩의 백분율입니다. AWS DeepRacer에서 숙련 된 모델을 평가하려면 다음을 수행하십시오.



  • Configure and start an evaluation job.

  • View the evaluation progress while the job is running.

  • View the evaluation summary after the job is done.

  • Terminate an evaluation job at any time.

    평가 작업을 구성하고 시작하십시오.
    작업이 실행되는 동안 평가 진행률을 봅니다.
    작업 완료 후 평가 요약을 봅니다.
    언제든지 평가 작업을 종료합니다.


AWS DeepRacer simulator

A virtual environment, set up as a racing track, within which our agent can act, receive rewards, and learn how to race around the track.

레이싱 트랙으로 설정되는 가상 환경. 상담원이 행동하고 보상을받으며 트랙 주위에서 경주하는 방법을 배웁니다.


AWS DeepRacer vehicle

See AWS DeepRacer


AWS DeepRacer car

A type of AWS DeepRacer vehicle that is a 1/18 scale model car.

1/18 의 비율로 축소된 모델 자동차 인 AWS DeepRacer 차량 유형입니다.


Machine-learning frameworks

Refer to the software libraries used for building machine learning algorithms. Supported frameworks for AWS DeepRacer include Tensorflow.

기계 학습 알고리즘을 작성하는 데 사용되는 소프트웨어 라이브러리를 참조하십시오. AWS DeepRacer에 지원되는 프레임 워크에는 Tensorflow가 포함됩니다.


Policy network

A policy network is the neural network that is trained. It takes video images as input and predicts the next step actions for the agent. Depending on the algorithm, it may also evaluate the value of current state.

정책 네트워크는 훈련 된 신경 네트워크입니다. 비디오 이미지를 입력으로 받아 에이전트의 다음 단계 조치를 예측합니다. 알고리즘에 따라 현재 상태 값을 평가할 수도 있습니다.


Optimization algorithm

An optimization algorithm is the algorithm used to train a model. For supervised training, it calls for optimization by minimizing a loss function with a particular strategy to update weights. For reinforcement learning, it implements optimization by maximizing the expected future rewards with a particular reward function.

최적화 알고리즘은 모델을 훈련시키는 데 사용되는 알고리즘입니다. 감독 학습의 경우, 가중치를 업데이트하기위한 특정 전략으로 손실 함수를 최소화하여 최적화를 요구합니다. 강화 학습의 경우 특정 보상 기능으로 예상되는 미래 보상을 최대화하여 최적화를 구현합니다.


Hyperparameters

Hyperparameters are the tunable parameters that can be used to optimize the training performance.

하이퍼 매개 변수는 교육 성능을 최적화하는 데 사용할 수있는 튜너블 매개 변수입니다.


AWS DeepRacer Track

An AWS DeepRacer track is the virtual environment on which a model is trained and on which the trained model can be evaluated.

AWS DeepRacer 트랙은 모델을 학습하고 훈련 된 모델을 평가할 수있는 가상 환경입니다.


Reward function

A reward function is a signaling function that indicates to the agent whether the action performed resulted in:

보상 기능은 수행 된 조치가 다음과 같은 결과를 가져 왔는지 여부를 에이전트에게 표시하는 신호 기능입니다.

  • A good outcome that should be reinforced.

  • A neutral outcome.

  • A bad outcome that should be discouraged.

    좋은 결과가 강화되어야합니다.
    중립적 인 결과.
    나쁜 결과는 벌을 주어야 합니다


The reward function is a critical component of reinforcement learning. It determines the behavior that the agent will learn by incentivizing specific actions over others. The user provides the reward function by using the Python language, and this reward function is used to train the reinforcement learning model by using the optimizing algorithm.

보상 기능은 보강 학습의 중요한 구성 요소입니다. 에이전트가 다른 사람들보다 특정 행동을 장려함으로써 행동을 결정합니다. 사용자는 Python 언어를 사용하여 보상 기능을 제공하며이 보상 기능은 최적화 알고리즘을 사용하여 강화 학습 모델을 학습하는 데 사용됩니다.

Total reward means the sum of all the reward the agent received during an episode.

총 보상은 에피소드 중에 상담원이받은 모든 보상의 합계를 의미합니다.


AWS DeepRacer Episode

Episode is one simulation iteration from the starting state, e.g., the start of the lap, to a termination state, going off-track, or finishing the lap.

에피소드는 시작 상태, 예를 들어 랩의 시작에서 종료 상태, 오프 트랙으로 진행하거나 랩을 완료하는 것과 같은 하나의 시뮬레이션 반복이다.





반응형
이전 1 다음