With the popularity of random smartphones, in everyday life, most people carry their phones with them when they do anything. If the sensor in the mobile phone is turned on, when the user moves, a large amount of user information can be collected, and based on this information, the current user's sports mode can be determined, such as walking, climbing stairs, descending stairs, sitting, standing, lying down, etc . Based on these sport modes, design different scenarios to add some interesting functions for fitness or sports applications (APP).
In smart phones, common position information sensors are acceleration sensors (Accelerometer) and gyroscopes (Gyroscope).
Acceleration sensor: used to measure changes in mobile speed and position changes;
Gyroscope: used to test the change of mobile phone's moving direction and rotation speed;
sensor
This article mainly trains the deep learning model based on the sensor data of the mobile phone to predict the user's movement pattern.
Technical solutions:
DL: DeepConvLSTM
Keras: 2.1.5
TensorFlow: 1.4.0
data
The data for this example comes from UCI (ie UC Irvine, University of California Irvine). The data consists of 30 volunteers aged between 19 and 48, with their smartphones fixed to their waists, performing six actions, namely walking, climbing stairs, descending stairs, sitting, standing, and lying down, while storing them on their phones Three-dimensional (XYZ axis) data of sensors (acceleration sensors and gyroscopes). The frequency of the sensor is set to 50 Hz (ie 50 recordings per second). For the dimensional data of the output sensor, perform a noise filter (Noise Filter), sliding in a fixed window of 2.56 seconds, and the window contains 50% overlap, that is, the data dimension of each window is 128 (2.56 * 50) dimensions Mark the data according to different sports categories. There are three types of sensors: body acceleration sensors, total acceleration sensors, and gyroscopes.
The following is the motion curve drawn according to the data. The amplitude of standing (red), sitting (green), and lying down (orange) is smaller, while the amplitude of walking (blue), up stairs (purple), and down stairs (black) is more Big.
Motion curve
The following is the motion curve of the three axes of the three types of sensors in walking (Walking), a total of 9-dimensional data:
Sensor-walking
The following is the movement curve in SitTIng:
Sensor-sitting
It can be seen from the observation that the sensor data curves of different sport modes have certain differences, but the differences of some sport modes are not obvious, such as walking, going up stairs, and down stairs; the sensor data curves of the same sport mode are also different. .
In the data source, 70% of the data is used as training data and 30% of the data is used as test data. The volunteers who generate training data are different from the test data to ensure the rigor of the data, which is consistent with the prediction of unknown user actions in practical applications. Guidelines.
UCI data source
model
The model is based on the DeepConvLSTM algorithm for deep learning. The algorithm combines ConvoluTIon and LSTM operations. It can learn both the spatial and temporal properties of samples. In the convolution operation, by multiplying the signal with the convolution kernel, the waveform signal is filtered, and high-level information is retained. In LSTM operation, the timing relationship between signals is discovered by memorizing or forgetting the preamble information.
The framework of DeepConvLSTM algorithm is as follows:
DeepConvLSTM
Combine the three coordinate axis (XYZ) data of each type of sensor (body acceleration, global acceleration, gyroscope) into a data matrix, namely (128, 3) dimension, as input data, each type of sensor creates a DeepConvLSTM There are 3 models in total. Through 3 convolution operations and 3 LSTM operations, the data is abstracted into 128-dimensional LSTM output vectors.
In CNN's convolution unit, through the combined operation of convolution (1x1 convolution kernel), BN, MaxPooling (2-dimensional chihua), and Dropout, three consecutive groups are performed, and the last group performs Dropout. Through MaxPooling's dimensionality reduction operation (2 ^ 3 = 8), the 128-dimensional data is converted into 16-dimensional high-level features.
CNN
In the RNN sequence unit, through the LSTM operation, the number of hidden layer neurons is set to 128, three consecutive times, the 16-dimensional convolution feature is converted into a 128-dimensional sequence feature, and then the Dropout operation is performed.
LSTM
Finally, the three models of the three sensors are output and merged into one input, that is, 128 * 3 = 384, and then the operations of Dropout, full connection (Dense), and BN are performed. Finally, the Softmax activation function is used to output 6 Probability of category.
Merged
Select the category with a higher probability as the final predicted motion mode.
effect
In the 48th layer, the Concatenate layer, the LSTM outputs of the three sensors are merged into one input. The characteristics of different categories have different effects, such as:
Merged Layer
Training parameters:
epochs = 100batch_size = 256kernel_size = 3pool_size = 2dropout_rate = 0.15n_classes = 6
The final result, in the test set, the accuracy rate is about 95%:
loss: 0.0131-acc: 0.9962-val_loss: 0.1332-val_acc: 0.9535val_f1: 0.953794 — val_precision: 0.958533 — val_recall 0.949101
If you continue to adjust the parameters, you can also improve accuracy.
The user action recognition model trained by the deep learning algorithm can be applied to the mobile terminal for scene detection, including six actions of walking, going up stairs, going down stairs, sitting, standing, and lying down. At the same time, 95% accuracy has met the needs of most products.
Product categories of Vozol, we are specialized electronic cigarette manufacturers from China, Vapes For Smoking, Vape Pen Kits, Vape Cartridge, Smoking Accessories,E-Cigarette suppliers/factory, wholesale high-quality products of Modern E-Cigarette R & D and manufacturing, we have the perfect
after-sales service and technical support. Look forward to your cooperation!
vozol disposable vape,puff bar vozol vape,vozol bar disposable vape kit,pod vozol bar vape,vozol vape pen
Ningbo Autrends International Trade Co.,Ltd. , https://www.mosvape.com