aws direct connect_aws transit gateway

(90) 2024-06-30 15:01:01

登录进AWS Control 控制台

搜索“DeepRacer”并点击“AWS DeepRacer”
aws direct connect_aws transit gateway (https://mushiming.com/)  第1张
DeepRacer 控制台。

aws direct connect_aws transit gateway (https://mushiming.com/)  第2张

2019 年 DeepRacer 冠军杯”的航点图

aws direct connect_aws transit gateway (https://mushiming.com/)  第3张

1. 如何获得航点地图?

1.1 打开“终端”

aws direct connect_aws transit gateway (https://mushiming.com/)  第4张

1.2. 下载文件。输入命令:

git clone https://github.com/aws-deepracer-community/deepracer-analysis.git 

aws direct connect_aws transit gateway (https://mushiming.com/)  第5张

1.3. 命令:

cd deepracer-analysis/ 

aws direct connect_aws transit gateway (https://mushiming.com/)  第6张

1.4.命令运行jupyter lab。

python3 -m venv venv source venv/bin/activate pip install --upgrade -r requirements.txt jupyter lab 

aws direct connect_aws transit gateway (https://mushiming.com/)  第7张

1.5. 点击“enter”运行最后一条命令。

aws direct connect_aws transit gateway (https://mushiming.com/)  第8张

2. Jupyter Lab将弹出。

aws direct connect_aws transit gateway (https://mushiming.com/)  第9张

2.1点击“Training_analysis.ipynb”

aws direct connect_aws transit gateway (https://mushiming.com/)  第10张

2.2.运行以下命令,使用“shift + enter”运行。

aws direct connect_aws transit gateway (https://mushiming.com/)  第11张

2.3.运行导入,使用“shift + enter”运行。

aws direct connect_aws transit gateway (https://mushiming.com/)  第12张

2.4. 列出曲目文件名。

aws direct connect_aws transit gateway (https://mushiming.com/)  第13张

2.5. 为 reinvent_base 加载航点地图。

aws direct connect_aws transit gateway (https://mushiming.com/)  第14张

2.6.您可以更改文件名以获得不同的航点地图。

aws direct connect_aws transit gateway (https://mushiming.com/)  第15张

3. 什么是航点waypoints?

航点代表轨道上的每个位置。它有 3 条线(L = 左、C = 中心和 R = 右),它们在地图上也有 0 - 154 号。不同的赛道会有不同的航点。
aws direct connect_aws transit gateway (https://mushiming.com/)  第16张
为航点构建新代理。

3.1 点击“你的车库”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第17张

3.2. 点击“建造新车”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第18张

3.3. 选择“相机”并点击“下一步”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第19张

3.4.修改动作空间。(最大转向角=20,转向角粒度=3,最大速度=2m/s,速度粒度=2)

aws direct connect_aws transit gateway (https://mushiming.com/)  第20张

3.5. 点击“下一步”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第21张

3.6. 命名 DeepRacer 并单击“完成”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第22张

4. 使用航点奖励功能创建新模型。

4.1.点击“创建模型”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第23张

4.2. 输入型号名称。

aws direct connect_aws transit gateway (https://mushiming.com/)  第24张

4.3.选择赛道:2019 DeepRacer冠军杯。

aws direct connect_aws transit gateway (https://mushiming.com/)  第25张

4.4.选择代理(与之前创建的相同)并单击“下一步”

aws direct connect_aws transit gateway (https://mushiming.com/)  第26张

4.5. 从 Github 复制奖励函数模板并粘贴到代码编辑器:

https://github.com/oscarYCL/deepracer-waypoints-workshop/blob/main/Template.py

def reward_function(params): center_variance = params["distance_from_center"] / params["track_width"] #racing line left_lane = [8,9,10,11,12,13,14,15,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,85,86,87,88,89,90,91,92,139,140,141,142,143,144,145,146,147,148,149,150,151]#Fill in the waypoints center_lane = [0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23,26,27,28,29,30,31,32,33,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,133,134,135,136,137,138,152,153,154]#Fill in the waypoints right_lane = [24,25,120,121,122,123,124,125,126,127,128,129,130,131,132]#Fill in the waypoints #Speed fast = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,141,142,143,144,145,146,147,148,149,150,151,152,153,154]#Fill in the waypoints, 2m/s slow = [83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,139,140]#Fill in the waypoints, 1m/s reward = 21 if params["all_wheels_on_track"]: reward += 10 else: reward -= 10 if params["closest_waypoints"][1] in left_lane and params["is_left_of_center"]: reward += 10 elif params["closest_waypoints"][1] in right_lane and not params["is_left_of_center"]: reward += 10 elif params["closest_waypoints"][1] in center_lane and center_variance < 0.4: reward += 10 else: reward -= 10 if params["closest_waypoints"][1] in fast: if params["speed"] == 2 : reward += 10 else: reward -= 10 elif params["closest_waypoints"][1] in slow: if params["speed"] == 1 : reward += 10 else: reward -= 10 return float(reward) 

aws direct connect_aws transit gateway (https://mushiming.com/)  第27张

5. 使用航路点的赛车线。

5.1 画出赛车线。

aws direct connect_aws transit gateway (https://mushiming.com/)  第28张

5.2. 将航点填入奖励功能。

aws direct connect_aws transit gateway (https://mushiming.com/)  第29张

5.3. 填写 right_lane 的航路点。航路点:48-55。

aws direct connect_aws transit gateway (https://mushiming.com/)  第30张
aws direct connect_aws transit gateway (https://mushiming.com/)  第31张

5.4. 填充 center_lane 的航路点。航路点:56-75。

aws direct connect_aws transit gateway (https://mushiming.com/)  第32张

aws direct connect_aws transit gateway (https://mushiming.com/)  第33张

5.5. 填充 left_lane 的航路点。航路点:76-90。

aws direct connect_aws transit gateway (https://mushiming.com/)  第34张
aws direct connect_aws transit gateway (https://mushiming.com/)  第35张

5.6.填写奖励功能的所有路点(0-154)。例子:

aws direct connect_aws transit gateway (https://mushiming.com/)  第36张

6. 在赛车线之后,我们可以使用航路点来控制速度。

设置快=2m/s,慢=1m/s。
aws direct connect_aws transit gateway (https://mushiming.com/)  第37张
aws direct connect_aws transit gateway (https://mushiming.com/)  第38张

6.1.画出速度线。绿线 = 2 m/s,红线 = 1m/s

aws direct connect_aws transit gateway (https://mushiming.com/)  第39张

6.2. 将航路点填到“快”。航路点 48-75。

aws direct connect_aws transit gateway (https://mushiming.com/)  第40张
aws direct connect_aws transit gateway (https://mushiming.com/)  第41张

6.3. 将航路点填到“慢”。航路点 76-90。

aws direct connect_aws transit gateway (https://mushiming.com/)  第42张
aws direct connect_aws transit gateway (https://mushiming.com/)  第43张

6.4.填写奖励功能的所有路点(0-154)。例子:

aws direct connect_aws transit gateway (https://mushiming.com/)  第44张

6.5. 完成奖励功能,设置训练时间=120分钟

aws direct connect_aws transit gateway (https://mushiming.com/)  第45张
aws direct connect_aws transit gateway (https://mushiming.com/)  第46张

6.6. 点击“创建模型”开始训练。

aws direct connect_aws transit gateway (https://mushiming.com/)  第47张

6.2小时后,培训结束。

aws direct connect_aws transit gateway (https://mushiming.com/)  第48张

7. 评估您的模型

7.1 点击“开始评估”。

点击“开始评估”。
aws direct connect_aws transit gateway (https://mushiming.com/)  第49张

7.2.选择赛道“2019 DeepRacer冠军杯”

aws direct connect_aws transit gateway (https://mushiming.com/)  第50张

7.3. 选择试验次数来评估您的模型(3 次试验)。

aws direct connect_aws transit gateway (https://mushiming.com/)  第51张

7.4. 赛车类型选择“计时赛”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第52张

7.5.点击“开始评估”

aws direct connect_aws transit gateway (https://mushiming.com/)  第53张

7.10分钟后,你会得到结果。

aws direct connect_aws transit gateway (https://mushiming.com/)  第54张
该模型有 2 个偏离轨道,因为它只完成了约 60%。我们需要更多的训练时间。

aws direct connect_aws transit gateway (https://mushiming.com/)  第55张

8.克隆你的模型

8.1 点击“克隆”

aws direct connect_aws transit gateway (https://mushiming.com/)  第56张

8.2. 输入型号名称。

aws direct connect_aws transit gateway (https://mushiming.com/)  第57张

8.3. 选择赛道。

aws direct connect_aws transit gateway (https://mushiming.com/)  第58张

8.4. 点击“下一步”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第59张

8.5. 点击“下一步”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第60张

8.6. 单击“超参数”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第61张

8.7. 将“学习率”从 0.0003 更改为 0.00003。

aws direct connect_aws transit gateway (https://mushiming.com/)  第62张
超参数。

aws direct connect_aws transit gateway (https://mushiming.com/)  第63张

8.8. 点击“创建模型”,再训练 120 分钟。

aws direct connect_aws transit gateway (https://mushiming.com/)  第64张

9. 120分钟后,二次训练结束。

9.重新开始评估。

aws direct connect_aws transit gateway (https://mushiming.com/)  第65张
奖励图对比。模型训练完成率从 60% 提高到 86.05%。

aws direct connect_aws transit gateway (https://mushiming.com/)  第66张
评价结果对比。最佳时间从 16.315s 减少到 14.896s,所有单圈完成率 100%。
aws direct connect_aws transit gateway (https://mushiming.com/)  第67张

10. 下载评估视频。

10.1 点击“复制到 S3”

aws direct connect_aws transit gateway (https://mushiming.com/)  第68张

10.2. 单击“创建新存储桶”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第69张

10.3. 勾选“视频”并点击“复制”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第70张

10.4. 点击“复制”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第71张

10.5. 成功并点击“查看”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第72张

10.6. 点击“视频/”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第73张

10.7. 点击“评估/”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第74张

10.8、点击“评估-xxxxxxxxxxxxxxx-xxxxxxxxxxxx/”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第75张

10.9. 点击“camera-45degree/”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第76张

10.10. 勾选方框。

aws direct connect_aws transit gateway (https://mushiming.com/)  第77张

10.11. 点击“下载”。

aws direct connect_aws transit gateway (https://mushiming.com/)  第78张

10.12. 成功。

aws direct connect_aws transit gateway (https://mushiming.com/)  第79张

11. 2018 Reward function

github 地址:https://github.com/zgpeace/deepracer-waypoints-workshop/tree/main/Examples/re:Invent%

def reward_function(params): center_variance = params["distance_from_center"] / params["track_width"] #racing line left_lane = [23,24,50,51,52,53,61,62,63,64,65,66,67,68]#Fill in the waypoints center_lane = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,25,26,27,28,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,54,55,56,57,58,59,60,69,70]#Fill in the waypoints right_lane = [29,30,31,32,33,34]#Fill in the waypoints #Speed fast = [0,1,2,3,4,5,6,7,8,9,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70]#Fill in the waypoints, 2m/s slow = [10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]#Fill in the waypoints, 1m/s reward = 21 if params["all_wheels_on_track"]: reward += 10 else: reward -= 10 if params["closest_waypoints"][1] in left_lane and params["is_left_of_center"]: reward += 10 elif params["closest_waypoints"][1] in right_lane and not params["is_left_of_center"]: reward += 10 elif params["closest_waypoints"][1] in center_lane and center_variance < 0.4: reward += 10 else: reward -= 10 if params["closest_waypoints"][1] in fast: if params["speed"] == 2 : reward += 10 else: reward -= 10 elif params["closest_waypoints"][1] in slow: if params["speed"] == 1 : reward += 10 else: reward -= 10 return float(reward) 

参考

https://www.linkedin.com/pulse/aws-deepracer-free-student-workshop-run-faster-using-your-cheuk-lam/?published=t
https://github.com/zgpeace/deepracer-waypoints-workshop

THE END

发表回复