International Journal of Electrical and Computer Engineering (IJECE) Vol. 13, No. 2, April 2023, pp. 2023~2029 ISSN: 2088-8708, DOI: 10.11591/ijece.v13i2.pp2023-2029 2023 Journal homepage: http://ijece.iaescore.com Human activity recognition with self-attention Yi-Fei Tan, Soon-Chang Poh, Chee-Pun Ooi, Wooi-Haw Tan Faculty of Engineering, Multimedia University, Cyberjaya, Malaysia Article Info ABSTRACT Article history: Received Mar 31, 2022 Revised Sep 15, 2022 Accepted Oct 13, 2022 In this paper, a self-attention based neural network architecture to address human activity recognition is proposed. The dataset used was collected using smartphone. The contribution of this paper is using a multi-layer multi-head self-attention neural network architecture for human activity recognition and compared to two strong baseline architectures, which are convolutional neural network (CNN) and long-short term network (LSTM). The dropout rate, positional encoding and scaling factor are also been investigated to find the best model. The results show that proposed model achieves a test accuracy of 91.75%, which is a comparable result when compared to both the baseline models. Keywords: Convolution neural network Human activity recognition Long short-term memory Self-attention This is an open access article under the CC BY-SA license. Corresponding Author: Yi-Fei Tan Faculty of Engineering, Multimedia University 63100 Cyberjaya, Selangor, Malaysia Email: yftan@mmu.edu.my 1. INTRODUCTION Around the world, the population of elderly is increasing rapidly. According to United Nations analysis of recent trends of elderly population, the population is predicted to increase to 2.1 billion by 2050 [1]. Department of Statistics Malaysia projected the elderly population to reach about 20% of total population [2]. Therefore, there are research which focused on improving elderly via assisted living technology [3]. One of the key technologies is activity recognition. Activity recognition is a task of recognizing human activities based on a series of observations of human actions [4]. Computer scientists addressed this task by using various machine learning algorithms which feed on the observational data of human actions and classify the given data into specific activity type. The observational data of activities can be collected by using different means such as sensors or cameras [5]–[7]. In this paper, the focus is on sensor-based activity recognition algorithm because sensory-based system is much less intrusive and lightweight when compared to vision-based methods. On-body sensors such as accelerometer and gyroscope can be used to collect acceleration and angular velocity of human body in various axis [8]–[11]. On-body sensors as data collectors are ubiquitous and prevalent in human activity recognition research because of their relatively low cost. For example, electronic devices such as smartphones, smart watches and wearable activity tracker have embedded accelerometer and gyroscope. Besides, they are not limited to any location because people can carry them everywhere. One of the limitations of using on-body sensors is the battery issue. The pattern of the time series sensory data for each type of activity is distinct. For example, time series acceleration of running should have a higher rate of change compared to walking. This unique distinction in pattern allows machine learning algorithm to classify them. The epplication of neural network architecture in human activity recognition has grown in recent years. Besides neural networks, there are several machine learning algorithms that were used for human activity recognition which include support vector machine (SVM) [12] and random forest (RF) [13]. Anguita et al. [12] used a dataset collected using smartphone’s inertial sensors. In this research, SVM which exploits