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閱讀 230,563評論 6 544
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,694評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,672評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,965評論 1 318
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,690評論 6 413
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 56,019評論 1 329
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 44,013評論 3 449
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 43,188評論 0 290
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,718評論 1 336
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,438評論 3 360
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,667評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,149評論 5 365
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,845評論 3 351
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,252評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,590評論 1 295
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,384評論 3 400
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,635評論 2 380

推薦閱讀更多精彩內容

  • 我希望有個如你一般的人,沒有來日方長,只有如今最好。 你在哪里,在地球一角的你還好嗎? 我曾經無數次想象過我們在一...
    耳朵聽你閱讀 195評論 0 0
  • 九月十三號,禮拜三輕書漫卷帶你走進醉美馬鞍山, 原始森林馬鞍山馬鞍山位于固陽縣城東南約58公里處,海拔1984米,...
    友聚戶外閱讀 266評論 0 0
  • 我們混跡的世界如此荒唐險惡 我們的未來如此變幻莫測 你卻說大家總要學習他的規則 誰來告訴 我怎么習慣一個又一個妥協...
    _Shen藍閱讀 146評論 0 0
  • 最近兩年,有孩子的家庭都對高考英語改革充滿了關注,甚至焦慮。很多家長問,我家孩子英語學的不錯,改革以后是不是就白學...
    簡單英語語法閱讀 913評論 0 1