LSTM Neural Network for Accelerometer Data Processing

LSTM Neural Network for Accelerometer Data Processing


You know first-hand that smartphones have auto-rotate settings. When you play mobile games, you can manage movements via the phone's rotation. Smartphones contain a special sensor called an accelerometer for supporting automatic orientation of the screen. The accelerometer measures acceleration of the object. Modern engineers collect data on mobile phones’ orientation changes to learn the way smartphone owners move. The data can be applied for software development in different areas — from providing security up to geolocation services.
How can we automate and systematize accelerometer data processing?
While answering this question we decided to test various LSTM neural network models for sensor data processing.
The goal of our research is to test whether the LSTM neural network can process the accelerometer sensor data and can be used to determine the type of mobile objects movements.
The goal of our research is to to test whether the LSTM neural network can process the accelerometer sensor data and can be used to determine the type of mobile objects movements.
Research Overview

  1. Identifying the main hypothesis2. Accelerometer data visual analysis3. LSTM neural network training4. Results of LSTM network testing for the testing mobile app
    Identifying the Main Hypothesis
    In theory, an accelerometer is a device measuring sum of object acceleration and gravity acceleration. The primary accelerometer looks like a weight suspended on a spring and supported from the other side to inhibit vibrations. Usually, smartphones have embedded MEMS accelerometers.
    The model of the primary accelerometer
    Image 1: The model of the primary accelerometer

Accelerometers can be single-, two-, and three-axis meaning that acceleration can be measured along with one, two, or three axises. Most smartphones typically make use of three-axis models.
We’ve used the accelerometer to determine whether a smartphone was moving or not and to see the speed of the movements.
When you give an acceleration to the smartphone – you take it up from the table or twist it in the air, the phone’s springs are stretching and compressing in a specific way. Considering the specifics of smartphone’s movements, we formulated the hypothesis.
The main hypothesis: if a smartphone is located inside a pocket of the moving object, oscillations are transmitted to the smartphone and displayed in the accelerometer data.
Accelerometer Data Visual Analysis
We analyzed the collected accelerometer data in accordance with the main hypothesis.

Image 2: Walk 1. Three-axis accelerometer sensor data

Image 3: Walk 2. Three-axis accelerometer sensor data

Image 4: Walk 3. Three-axis accelerometer sensor data

We found in the following pattern in the data. In the moment of making a step, an oscillation of a big amplitude occurs and then disappears till the next step is made. This pattern is repeated on all the graphs:
Walk 1. In the range of 600 to 1300
Walk 2. In the range of 500 to 1300
Walk 3. In the range of 300 to 1500

However, various factors can add some noise to the accelerometer data processing. For example, the phone can be located inside the pocket and sit differently. In this case, graphs for all the three axes with the same model of object movements will look differently to how it’s shown on the images.
If you look at the Y-axis on the graphs, then you’ll see that the phone was located in different positions. For this reason, it was required to find a feature that doesn’t depend on the smartphone’s position and shows the specific pattern for various types of human movements at the same time. The magnitude of the vector was chosen as the required feature. The vector starts from the origin and goes to the point with X, Y, Z coordinates from the accelerometer sensor data.

Image 5: Walk 1. Three-axis accelerometer sensor data including the graph for the magnitude of the vector oscillations

Image 6: Walk 2. Three-axis accelerometer sensor data including the graph for the magnitude of the vector oscillations

Image 7: Walk 3. Three-axis accelerometer sensor data including the graph for the magnitude of the vector oscillations

As you can see from graph, the vector magnitude doesn’t depend on the smartphone position.
LSTM Neural Network Training
To solve the task, we made a dataset divided into the training and testing sets. Then we started to train the LSTM neural network.
All the models have the same structure of the network layers: the input vector goes to the LSTM layer and then a signal goes to the fully connected layer where the answer comes from. Detailed information can be found, for instance, on the website of Lasagne framework.
To get the optimal model we wrote a script that created new models by changing the number of inputs in neural networks and the LSTM-elements number. We created and trained all the model types several times to avoid entering local minimum while using the solver and finding the optimal set of the network weights.
All the models are implemented using Python with frameworks Theano and Lasagne. We’ve also applied the Adam solver. The differences between models are the size of input vector and the LSTM-elements number.
We then tested received models with a special Android testing app. To run the solution on Android, we chose the following libraries:
JBLAS is a linear algebra library based on BLAS (Basic Linear Algebra Subprograms)
JAMA – Java Matrix Package

The library JBLAS showed an error message when the program was running on the arm64 architecture. Finally, we implemented the solution using JAMA.
Results of LSTM Network Testing for the Testing Mobile App
Results of LSTM network testing demonstrated that the received models cope well with the accelerometer data processing tasks.

Image 8: The Results of Model Testing

Using the models, we can define the type of mobile object movements: rest, on foot, driving, etc. This is explained via a specific pattern that appears in the oscillations of vector length that are calculated with accelerometer data in driving or rest periods.
When it relates to on foot or the rest, a pattern is quite easily followed. When it relates to a transport trip (subway, bus, or car), the precision of estimation falls down as different factors influence the correct evaluation of the human state.

Image 9: Results of model testing based on accelerometer data from the walk and from the bus trip

Usually, a man doesn’t move in the transport. Hence, most of the way will be shown as rest. However, if a man is in a shaky type of transport, the vibration will transmit to the smartphone and the neural network will define the movement type as transport. When it relates to the car, a driver can allocate the phone on the control panel. In this case, the pattern transport will be better followed.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,884评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,347评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,435评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,509评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,611评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,837评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,987评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,730评论 0 267
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,194评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,525评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,664评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,334评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,944评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,764评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,997评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,389评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,554评论 2 349

推荐阅读更多精彩内容

  • 我希望有个如你一般的人,没有来日方长,只有如今最好。 你在哪里,在地球一角的你还好吗? 我曾经无数次想象过我们在一...
    耳朵听你阅读 193评论 0 0
  • 九月十三号,礼拜三轻书漫卷带你走进醉美马鞍山, 原始森林马鞍山马鞍山位于固阳县城东南约58公里处,海拔1984米,...
    友聚户外阅读 249评论 0 0
  • 我们混迹的世界如此荒唐险恶 我们的未来如此变幻莫测 你却说大家总要学习他的规则 谁来告诉 我怎么习惯一个又一个妥协...
    _Shen蓝阅读 75评论 0 0
  • 最近两年,有孩子的家庭都对高考英语改革充满了关注,甚至焦虑。很多家长问,我家孩子英语学的不错,改革以后是不是就白学...
    简单英语语法阅读 887评论 0 1