2022/9/6
1
DNN Lab 1 and 3
• Lab 1 (DNN supervised learning): Titanic Survival Predication
• Lab 3 (DNN supervised learning): curve learning
• Lab 7 (reinforcement learning): Q Learning maze
• Lab 8 (reinforcement learning): Open AI : Mountain Car
• Lab 9 (reinforcement learning): Open AI :CartPole
• Lab 2 (CNN supervised learning): image classification- ImageNet
• Lab 5 (CNN supervised learning): handwriting number classification- Mnist
• Lab 6 (CNN supervised learning): object detection- SSD (Single Shot MultiBox Detector)
• Lab 4 (RNN supervised learning)
2
2022/9/6
Three levels for lab1-12 reports
• (Minimum) Run the program and get reasonable result, e.g, accuracy around 90%
• Tune the hyperparameters to get better result
• Change the dataset and get acceptable results
3
(tensorflow) C:> Lab01_titanic_survival_prediction
(tensorflow) C:> python titanic_survival_predictation.py
(tensorflow) C:> 可自行修改輸入資料,看結果合不合理?
(tensorflow) C:> cd..
(tensorflow) C:> cd Lab03_plot_result
(tensorflow) C:> python plot_result.py
(tensorflow) C:> 可自行修改輸入曲線,看是否可以訓練成功?
(tensorflow) C:> cd..
Run Lab01 and Lab03
4
2022/9/6
Lab01 Titanic Survival
Prediction
↓
PM2.5 Exceeded Prediction (Change
dataset!)
職電子碩㇐ 110368505 劉蘋慧
110368526 蕭銘宏
110368529 林佑軒
110368540 李品濬
Abstract
● Titanic survival prediction
In this case, we learned how to use TFLearn and TensorFlow to model the survival chance of
titanic passengers using their personal information (such as gender, age, and so on). To
tackle this classic machine learning task, we are going to build a DNN classifier.
2022/9/6
Abstract
● PM2.5 exceeded prediction
Based on the case of titanic survival predictor, we used and preprocessed the dataset from
fengyuan automatic meteorological observation station to predict the chance if the
concentration of PM2.5 will exceed the standard.
Table of contents
a. Dataset parameters
b. Source code introduction
c. Source code modification
d. Conclusion
PM2.5 Exceeded Prediction
01 02
Titanic Survival Prediction
a. Introduction
b. Dataset preprocessing
c. Source code modification
d. Conclusion
2022/9/6
Titanic Survival
Prediction
01
Dataset parameters
Dataset with titanic passengers’ personal
information.
survived (0 = No; 1 = Yes)
pclass Passenger Class (1 = st; 2 = nd; 3 = rd)
name Name
sex Sex
age Age
sibsp Number of Siblings/Spouses Aboard
parch Number of Parents/Children Aboard
ticket Ticket Number
fare Passenger Fare
2022/9/6
Titanic Survival
Prediction
01
Source code introduction
Load dataset csv
file.
Define a function to preprocess
data.
Ignore index 1 and 6
columns.
2022/9/6
Default use 2 layers of neural
network.
Softmax activation maps inputs to real numbers between 0-1,
and guarantees the sum of chances of all categories is 1.
Batch size Number of samples used for one iteration of gradient descent
Epoch Number of times that the learning algorithm work through all training samples
Changing the values of these two parameters will influence the accuracy of the prediction and the
surviving rate of DiCaprio and Winslet.
2022/9/6
Prepare the test data and predict the surviving
rates.
Titanic Survival
Prediction
01
Source code modification
2022/9/6
Add this line at the beginning of the code to remove nodes from graph
or reset entire default graph, and prevent the error below.
Add a new layer of the neural network, and modify
the nodes of these layers to 128, 64 and 32
respectively.
Keep the values of epoch and batch
size.
2022/9/6
Titanic Survival
Prediction
01
Conclusion
After modifying the structure of
the neural network, the accuracy
is improved from 0.77 to
0.81.
2022/9/6
PM2.5 Exceeded
Prediction
02
Introduction
PM2.5 standard Classify these four levels to two
categories.
1:Dangerous
0:Great
2022/9/6
We prepared the real data of fengyuan automatic weather station (AWS)
from Central Weather Bureau(CWB) to be the dataset for predicting the
chance if the concentration of PM2.5 will exceed.
PM2.5 Exceeded
Prediction
02
Dataset preprocessing
2022/9/6
We need to preprocess the dataset and let it fit the
input model format of the neural network in TFLearn.
2022/9/6
List all data to an one-dimensional
array with the sorted 18 parameters.
Reshape data to 320x18 array. (18 a
group)
Insert id numbers to the first
column.
Add parameters row and export the dataset csv
file.
2022/9/6
Classify and mask the values of PM2.5 to 0 and
1.
PM2.5 Exceeded
Prediction
02
Source code modification
2022/9/6
Designate PM2.5 as target predict
parameter.
Based on the case of titanic survival predictor, we modified
the input data shape to 17 and kept the number of the
layers and the nodes of these layers.
17 = 18 parameters – 1 (PM2.5 as predict target
parameter)
2022/9/6
Modify the value of epoch and observe the accuracy and the
loss rate. We found that the value of epoch is 15, the best
accuracy it will be. If exceeding 15, the overfitting would happen.
Meanwhile, we modified the value of batch size to 20.
Prepare the test data and predict the exceeded
rates.
2022/9/6
PM2.5 Exceeded
Prediction
02
Conclusion
The accuracy of the prediction can achieve to
0.92.
2022/9/6
AI Lab3 Report– 視覺化神經網路
利用TensorFlow進行非線性回歸計算
授課教授:曾恕銘
系所:自動化職碩㇐
學生姓名:109618515 趙國桓
109618512 彭凱群
AI Lab3 – 視覺化神經網路
• Tensorflow 特點:
1. 強大的機器學習框架
2. 開源且免費
3. 最新版至少支援六種程式語言
4. 使用者可在瀏覽器內訓練並執行模型
5. 針對小型可攜設備,TensorFlow有輕量化版本
jc1
jc2
投影片 38
jc1 jonathan chao, 2021/6/24
jc2 jonathan chao, 2021/6/24
2022/9/6
39
Ai lab3 – 視覺化神經網路
首先設定神經網路層數,
同時也把權重定義在這
裡
40
• 下方的程式碼是用來定義公式, AI Lab3的兩個題目只有公式不同
2022/9/6
41
這㇐段程式碼主要重點為 -
o 定義㇐個簡單的神經網
路
o 設定代價函數
o 採用梯度訓練法讓預測
值接近
o 畫出資料點位
42
• 下方的程式碼是用來
做1000次迭代並且
用紅色作為最接近的
資料點連接, 最後執
行時會看到㇐條中心
線會因為資料變化接
近中點
2022/9/6
43
AI Lab3 執行結果
• 上方為完整主程式展示結果
• 下方為例題展示結果
挑戰點
1. 因為㇐直出現呼叫問題, 所以刪除所有環境, 重新安裝
anaconda和tensorflow module
2. 逐行執行程式進行修改
3. 找出兩個function call定義問題
4. ㇐個個module screen 看看還有沒有定義的問題
2022/9/6
原始開發者yt 影片
• https://www.youtube.com/watch?v=ZGPfyB7ZFK8&t=269s
• https://www.youtube.com/watch?v=nslbfsN8wiU

AIML2 DNN lab 1 3 1hr (111-1).pdf

  • 1.
    2022/9/6 1 DNN Lab 1and 3 • Lab 1 (DNN supervised learning): Titanic Survival Predication • Lab 3 (DNN supervised learning): curve learning • Lab 7 (reinforcement learning): Q Learning maze • Lab 8 (reinforcement learning): Open AI : Mountain Car • Lab 9 (reinforcement learning): Open AI :CartPole • Lab 2 (CNN supervised learning): image classification- ImageNet • Lab 5 (CNN supervised learning): handwriting number classification- Mnist • Lab 6 (CNN supervised learning): object detection- SSD (Single Shot MultiBox Detector) • Lab 4 (RNN supervised learning) 2
  • 2.
    2022/9/6 Three levels forlab1-12 reports • (Minimum) Run the program and get reasonable result, e.g, accuracy around 90% • Tune the hyperparameters to get better result • Change the dataset and get acceptable results 3 (tensorflow) C:> Lab01_titanic_survival_prediction (tensorflow) C:> python titanic_survival_predictation.py (tensorflow) C:> 可自行修改輸入資料,看結果合不合理? (tensorflow) C:> cd.. (tensorflow) C:> cd Lab03_plot_result (tensorflow) C:> python plot_result.py (tensorflow) C:> 可自行修改輸入曲線,看是否可以訓練成功? (tensorflow) C:> cd.. Run Lab01 and Lab03 4
  • 3.
    2022/9/6 Lab01 Titanic Survival Prediction ↓ PM2.5Exceeded Prediction (Change dataset!) 職電子碩㇐ 110368505 劉蘋慧 110368526 蕭銘宏 110368529 林佑軒 110368540 李品濬 Abstract ● Titanic survival prediction In this case, we learned how to use TFLearn and TensorFlow to model the survival chance of titanic passengers using their personal information (such as gender, age, and so on). To tackle this classic machine learning task, we are going to build a DNN classifier.
  • 4.
    2022/9/6 Abstract ● PM2.5 exceededprediction Based on the case of titanic survival predictor, we used and preprocessed the dataset from fengyuan automatic meteorological observation station to predict the chance if the concentration of PM2.5 will exceed the standard. Table of contents a. Dataset parameters b. Source code introduction c. Source code modification d. Conclusion PM2.5 Exceeded Prediction 01 02 Titanic Survival Prediction a. Introduction b. Dataset preprocessing c. Source code modification d. Conclusion
  • 5.
    2022/9/6 Titanic Survival Prediction 01 Dataset parameters Datasetwith titanic passengers’ personal information. survived (0 = No; 1 = Yes) pclass Passenger Class (1 = st; 2 = nd; 3 = rd) name Name sex Sex age Age sibsp Number of Siblings/Spouses Aboard parch Number of Parents/Children Aboard ticket Ticket Number fare Passenger Fare
  • 6.
    2022/9/6 Titanic Survival Prediction 01 Source codeintroduction Load dataset csv file. Define a function to preprocess data. Ignore index 1 and 6 columns.
  • 7.
    2022/9/6 Default use 2layers of neural network. Softmax activation maps inputs to real numbers between 0-1, and guarantees the sum of chances of all categories is 1. Batch size Number of samples used for one iteration of gradient descent Epoch Number of times that the learning algorithm work through all training samples Changing the values of these two parameters will influence the accuracy of the prediction and the surviving rate of DiCaprio and Winslet.
  • 8.
    2022/9/6 Prepare the testdata and predict the surviving rates. Titanic Survival Prediction 01 Source code modification
  • 9.
    2022/9/6 Add this lineat the beginning of the code to remove nodes from graph or reset entire default graph, and prevent the error below. Add a new layer of the neural network, and modify the nodes of these layers to 128, 64 and 32 respectively. Keep the values of epoch and batch size.
  • 10.
    2022/9/6 Titanic Survival Prediction 01 Conclusion After modifyingthe structure of the neural network, the accuracy is improved from 0.77 to 0.81.
  • 11.
    2022/9/6 PM2.5 Exceeded Prediction 02 Introduction PM2.5 standardClassify these four levels to two categories. 1:Dangerous 0:Great
  • 12.
    2022/9/6 We prepared thereal data of fengyuan automatic weather station (AWS) from Central Weather Bureau(CWB) to be the dataset for predicting the chance if the concentration of PM2.5 will exceed. PM2.5 Exceeded Prediction 02 Dataset preprocessing
  • 13.
    2022/9/6 We need topreprocess the dataset and let it fit the input model format of the neural network in TFLearn.
  • 14.
    2022/9/6 List all datato an one-dimensional array with the sorted 18 parameters. Reshape data to 320x18 array. (18 a group) Insert id numbers to the first column. Add parameters row and export the dataset csv file.
  • 15.
    2022/9/6 Classify and maskthe values of PM2.5 to 0 and 1. PM2.5 Exceeded Prediction 02 Source code modification
  • 16.
    2022/9/6 Designate PM2.5 astarget predict parameter. Based on the case of titanic survival predictor, we modified the input data shape to 17 and kept the number of the layers and the nodes of these layers. 17 = 18 parameters – 1 (PM2.5 as predict target parameter)
  • 17.
    2022/9/6 Modify the valueof epoch and observe the accuracy and the loss rate. We found that the value of epoch is 15, the best accuracy it will be. If exceeding 15, the overfitting would happen. Meanwhile, we modified the value of batch size to 20. Prepare the test data and predict the exceeded rates.
  • 18.
  • 19.
    2022/9/6 AI Lab3 Report–視覺化神經網路 利用TensorFlow進行非線性回歸計算 授課教授:曾恕銘 系所:自動化職碩㇐ 學生姓名:109618515 趙國桓 109618512 彭凱群 AI Lab3 – 視覺化神經網路 • Tensorflow 特點: 1. 強大的機器學習框架 2. 開源且免費 3. 最新版至少支援六種程式語言 4. 使用者可在瀏覽器內訓練並執行模型 5. 針對小型可攜設備,TensorFlow有輕量化版本 jc1 jc2
  • 20.
    投影片 38 jc1 jonathanchao, 2021/6/24 jc2 jonathan chao, 2021/6/24
  • 21.
    2022/9/6 39 Ai lab3 –視覺化神經網路 首先設定神經網路層數, 同時也把權重定義在這 裡 40 • 下方的程式碼是用來定義公式, AI Lab3的兩個題目只有公式不同
  • 22.
    2022/9/6 41 這㇐段程式碼主要重點為 - o 定義㇐個簡單的神經網 路 o設定代價函數 o 採用梯度訓練法讓預測 值接近 o 畫出資料點位 42 • 下方的程式碼是用來 做1000次迭代並且 用紅色作為最接近的 資料點連接, 最後執 行時會看到㇐條中心 線會因為資料變化接 近中點
  • 23.
    2022/9/6 43 AI Lab3 執行結果 •上方為完整主程式展示結果 • 下方為例題展示結果 挑戰點 1. 因為㇐直出現呼叫問題, 所以刪除所有環境, 重新安裝 anaconda和tensorflow module 2. 逐行執行程式進行修改 3. 找出兩個function call定義問題 4. ㇐個個module screen 看看還有沒有定義的問題
  • 24.