ST AEKD-AICAR1 User Manual Download Page 35

Contents

1

Neural network basic principles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2

1.1

Artificial neural network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2

Long short-term memory recurrent neural network (LSTM RNN) . . . . . . . . . . . . . . . . . . . . . . . 2

2

Designing an AI-car sensing node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

2.1

Tool-set introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2

Creating a Google Colab notebook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.3

Colab notebook setup and package importing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.4

AI-car sensing node life cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.4.1

Model definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.4.2

Model training . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.4.3

Model fitting and compilation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.4.4

Model evaluation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3

AutoDevKit ecosystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14

3.1

SPC5-STUDIO-AI plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3.1.1

How to import SPC5-STUDIO-AI using the standard importing procedure . . . . . . . . . . . . 16

3.1.2

How to import the pretrained LSTM neural network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.1.3

How to analyze the pretrained LSTM neural network . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.2

SPC5-STUDIO-AI API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4

AI-car sensing node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23

4.1

Precautions for use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

4.2

Hardware overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

4.3

Software architecture overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

4.3.1

Low-level software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.3.2

High-level software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.3.3

Main application software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

5

Test and results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27

5.1

Environment setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

5.2

Test performed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

5.3

Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

6

Schematic diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28

7

Bill of materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29

Appendix A

Regulatory compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30

Appendix B

Google Colab code for the neural network training . . . . . . . . . . . . . . . . . . . . . . .31

Appendix C

Python script code for the data acquisition and parsing . . . . . . . . . . . . . . . . . .33

UM3053

Contents

UM3053

 - 

Rev 1

page 35/39

Summary of Contents for AEKD-AICAR1

Page 1: ...ented and trained using the TensorFlow 2 4 0 framework Keras in the Google Colab environment The AI SPC5Studio plug in has been used to convert the resulting trained neural network into an optimized C...

Page 2: ...ty The bias is the measure of assumption made by the form of the output This architecture is typical for deep learning processes like data classification and pattern recognition neural networks 1 2 Lo...

Page 3: ...rk able to keep the information received is the long short term memory LSTM recurrent network Unlike traditional artificial neural networks LSTM has feedback connections It can process not only single...

Page 4: ...ms related to the classification problem A significant amount of computing power is required to implement sufficiently robust and efficient models For initial tests we can rely on a standard machine A...

Page 5: ...r large multidimensional arrays and matrices along with a large collection of high level mathematical functions to operate on these arrays import numpy as np Tensorflow Open source software library fo...

Page 6: ...speech recognition system It consists of a neural convolution kernel as an input layer able to elaborate a convolution function with the input vector over a temporal dimension The input vector is a ti...

Page 7: ...rs define the AI car sensing node network model These parameters are related to the LSTM RNN topology chosen 2 4 2 Model training The AI car sensing node network training has been performed by acquiri...

Page 8: ...nables the acquisition mode In this mode the application sends each acceleration sample read from the sensor to a serial port with a baud rate set to 38400 The serial data stream can be read through a...

Page 9: ...hree columns contain the acceleration values measured on the X Y and Z axis respectively without the gravity offset To prepare the file for the network training you have to Compute the acceleration va...

Page 10: ...eady to use dataset Diff_profile csv has been created to train the network for the car state classification 2 4 2 2 Neural network training with Google Colab Import the training dataset contained in t...

Page 11: ...ts_diff_Az i cnt 1 Note The cnt variable contains the number of available window waveforms according to the dataset acquired during each specific car status 2 4 3 Model fitting and compilation Firstl...

Page 12: ...it but faster than the training phase A confusion matrix performs the model accuracy evaluation This is a technique to summarize the algorithm classification performance As the datasets have differen...

Page 13: ...three have been confused with bumpy Figure 11 Confusion matrix The LSTM RNN accuracy for the AI car sensing node is about 93 The miss classification for the skid state impact the calculated accuracy v...

Page 14: ...ient ANSI C library to be compiled installed and executed on SPC58 microcontrollers You can easily import pretrained neural networks in the SPC5 STUDIO AI from the most widely used deep learning frame...

Page 15: ...2 Insert http ai spc5studio com in the Work with field Figure 13 Install new software Step 3 Click on Select all and Next Step 4 Install SPC5 STUDIO AI UM3053 SPC5 STUDIO AI plugin UM3053 Rev 1 page 1...

Page 16: ...n based on the SPC58ECxx platform Figure 14 Creating a new SPC5 STUDIO application Step 2 Import the following components AutodevKit Init Package SPC58ECxx Init Package Component RLA Step 3 Select SPC...

Page 17: ...ect SPC5 AI Component RLA Figure 17 Selecting SPC5 AI Component RLA 3 1 2 How to import the pretrained LSTM neural network The following procedure shows how to import the pretrained LSTM neural networ...

Page 18: ...option Step 4 Configure the parameters for the LSTM AI car sensing node Figure 20 Configuring the parameters Step 4a Enable the network initialization data Step 4b Put a valid neural network name Ste...

Page 19: ...M neural network To analyze the pretrained LSTM neural network for the AI car sensing node follow the procedure below Step 1 Select Analyze in the Outline tab Figure 21 Selecting Analyze UM3053 SPC5 S...

Page 20: ...components spc5_ai_component_rla cfg model_name model_car_sts model_hash 10794f1c230799b2a1cda67171827db2 input input_0 150 items 600 B ai_float FLOAT32 50 1 3 inputs total 600 B output dense_1_nl 4...

Page 21: ...eprocessor on how to configure properly the dimension and allocation of the neural network data structure Table 1 List of defines C language define Description AI_SENSING_NODE_NETWORK_MODEL_NAME A C s...

Page 22: ...the ai_sensing_node_network_destroy function should be called to release the possible allocated resources ai_sensing_node_network_init ai_bool ai_sensing_init ai_handle network const ai_network_params...

Page 23: ...AICAR1 uses the AEK MCU C4MLIT1 evaluation board to process discrete acceleration variations acquired from the three axis IMU system in order to run a pretrained neural network Moreover the board dri...

Page 24: ...follow the procedure below Step 1 Go on SPC58ECxx Platform Component RLA in the project explorer and add a new AEK CON SENSOR1 Component RLA from the list Step 2 Press on the allocation button to mak...

Page 25: ...el_data PIXFMT_RGB_565 aek_ili9341_drawString AEK_LCD_DEV0 102 160 PARKING color font24pt 4 3 2 High level software This layer includes IMU middleware AI sensing node network middleware LCD display mi...

Page 26: ...AICAR1 application has three operating working modes Acquisition Real time calculation default Offline calculation 4 3 3 1 Acquisition This working mode is used to perform an LSTM neural network train...

Page 27: ...s Table 2 Test conditions and results Test condition Number of tests Number of failures Failure percentage Normal road 10 0 0 Bumpy road 10 0 0 Skid normal road 10 2 detected as bumpy road 20 Skid bum...

Page 28: ...CON SENSOR1 AEK LCD DT028V1 and STEVAL MKI206V1 You can find their detailed schematic diagrams at the related web pages AEK MCU C4MLIT1 schematic diagrams AEK CON SENSOR1 schematic diagrams AEK LCD DT...

Page 29: ...K CON SENSOR1 AEK LCD DT028V1 and STEVAL MKI206V1 You can find their detailed schematic diagrams at the related web pages AEK MCU C4MLIT1 bill of materials AEK CON SENSOR1 bill of materials AEK LCD DT...

Page 30: ...the authority of an FCC license holder or must secure an experimental authorization under part 5 of this chapter 3 1 2 Notice for Innovation Science and Economic Development Canada ISED For evaluatio...

Page 31: ...ame_size x a i i frame_size db_x append x db_y append Y_LABELS label db pd read_csv Diff_profile csv sep print db keys states db Status value_counts scaler MinMaxScaler ts_status db Status ts_diff_Ax...

Page 32: ...egorical_crossentropy metrics accuracy model fit x_train y_train epochs 1000 model summary import matplotlib pyplot as plt import seaborn as sns matplotlib inline Y_pred model predict x_test y_pred np...

Page 33: ...csv module csv_writer writer write_obj Add contents of list as last row in the csv file csv_writer writerow list_of_elem s sr Serial COM31 38400 Write header named_tuple time localtime get struct_tim...

Page 34: ...Revision history Table 3 Document revision history Date Revision Changes 20 Sep 2022 1 Initial release UM3053 UM3053 Rev 1 page 34 39...

Page 35: ...using the standard importing procedure 16 3 1 2 How to import the pretrained LSTM neural network 17 3 1 3 How to analyze the pretrained LSTM neural network 19 3 2 SPC5 STUDIO AI API 21 4 AI car sensin...

Page 36: ...Revision history 34 List of tables 37 List of figures 38 UM3053 Contents UM3053 Rev 1 page 36 39...

Page 37: ...List of tables Table 1 List of defines 21 Table 2 Test conditions and results 27 Table 3 Document revision history 34 UM3053 List of tables UM3053 Rev 1 page 37 39...

Page 38: ...plete model generation 12 Figure 11 Confusion matrix 13 Figure 12 Installing the plugin 14 Figure 13 Install new software 15 Figure 14 Creating a new SPC5 STUDIO application 16 Figure 15 Selecting the...

Page 39: ...s and ST assumes no liability for application assistance or the design of purchasers products No license express or implied to any intellectual property right is granted by ST herein Resale of ST prod...

Reviews: