• Stars
    star
    215
  • Rank 179,682 (Top 4 %)
  • Language
    Python
  • Created almost 7 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tutorial for using deep learning for activity recognition (Pytorch and Tensorflow)

Deep Learning for Human Activity Recognition

Deep learning is perhaps the nearest future of human activity recognition. While there are many existing non-deep method, we still want to unleash the full power of deep learning. This repo provides a demo of using deep learning to perform human activity recognition.

We support both Tensorflow and Pytorch.

Prerequisites

  • Python 3.x
  • Numpy
  • Tensorflow or Pytorch 1.0+

Dataset

There are many public datasets for human activity recognition. You can refer to this survey article Deep learning for sensor-based activity recognition: a survey to find more.

In this demo, we will use UCI HAR dataset as an example. This dataset can be found in here.

Of course, this dataset needs further preprocessing before being put into the network. I've also provided a preprocessing version of the dataset as a .npz file so you can focus on the network (download HERE). It is also highly recommended you download the dataset so that you can experience all the process on your own.

#subject #activity Frequency
30 6 50 Hz

Usage

  • For Pytorch (recommend), go to pytorch folder, config the folder of your data in config.py', and then run main_pytorch.py`.

  • For tensorflow, run main_tensorflow.py file. The update of tensorflow version is stopped since I personally like Pytorch.

Network structure

What is the most influential deep structure? CNN it is. So we'll use CNN in our demo.

CNN structure

Convolution + pooling + convolution + pooling + dense + dense + dense + output

That is: 2 convolutions, 2 poolings, and 3 fully connected layers.

About the inputs

That dataset contains 9 channels of the inputs: (acc_body, acc_total and acc_gyro) on x-y-z. So the input channel is 9.

Dataset providers have clipped the dataset using sliding window, so every 128 in .txt can be considered as an input. In real life, you need to first clipped the input using sliding window.

So in the end, we reformatted the inputs from 9 inputs files to 1 file, the shape of that file is [n_sample,128,9], that is, every windows has 9 channels with each channel has length 128. When feeding it to Tensorflow, it has to be reshaped to [n_sample,9,1,128] as we expect there is 128 X 1 signals for every channel.

Related projects

More Repositories

1

transferlearning

Transfer learning / domain adaptation / domain generalization / multi-task learning etc. Papers, codes, datasets, applications, tutorials.-迁移学习
Python
12,927
star
2

transferlearning-tutorial

《迁移学习简明手册》LaTex源码
TeX
2,455
star
3

MachineLearning

一些关于机器学习的学习资料与研究介绍
1,927
star
4

activityrecognition

Resources about activity recognition-行为识别资料
MATLAB
878
star
5

tlbook-code

Code for Transfer Learning book--《迁移学习导论》配套代码
Python
234
star
6

Pytorch-CapsuleNet

An easy-to-follow Pytorch implementation of Hinton's Capsule Network
Python
162
star
7

ProbabilityHomework

中国科学院大学(计算所)《概率方法与随机图》课程作业与教材
TeX
55
star
8

EasyEspnet

Making Espnet easier to use
Python
50
star
9

aqistudy

全国122个城市历史空气质量爬取
Python
40
star
10

maml

Python implementation MAML (model-agnostic meta learning)
Python
26
star
11

informationretrieval

信息检索检索器的Java实现
Roff
17
star
12

BUAA-Recommend-Graduate-Test

北航2013年计算机夏令营机试题,2 problems written in C language,2013
C++
9
star
13

graph

Java实现图,邻接矩阵和邻接表两种方式
Java
8
star
14

ActivationMapVisualization

Visualize the activation map using Grad CAM
Jupyter Notebook
7
star
15

kaggle-bikesharing

Python
6
star
16

DataBaseOperation

Java和C#简单的数据库操作类,支持Sql Server和Sqlite及mysql
C#
4
star
17

learning_to_match

Jupyter Notebook
3
star
18

jindongwang

2
star
19

SyntaxAnalysis

syntax analytics
C#
2
star