CNN-Model / README.md
hamzaN1's picture
Update README.md
47016a0 verified
|
Raw History Blame Contribute Delete
2.74 kB
metadata
license: mit
tags:
  - keras
  - tensorflow
  - time-series-classification
  - sensor-data
  - deep-learning-lab

Wearable Activity Classifier — CNN

Model description

A 1D Convolutional Neural Network that classifies short wearable-sensor sequences into three physical activities: Stationary, Walking, and Running. Built as part of a beginner deep learning group lab comparing CNN, SimpleRNN, LSTM, and a CNN+LSTM hybrid on the same fixed dataset.

Intended use

Educational demonstration of sequence classification on wearable sensor data. Not intended for production health/fitness monitoring.

Architecture

Input (100 time steps, 1 sensor channel) → Conv1D(32 filters, kernel_size=5, activation="relu") → MaxPooling1D(pool_size=2) → Flatten() → Dense(32, activation="relu") → Dense(3, activation="softmax")

Total parameters: 49,475

Training data

Fixed Wearable_Activity_Dataset release (seed 42 split): 600 training sequences, 150 validation, 150 test — each sequence is 100 time steps of a single sensor reading. Training set is perfectly class-balanced (200 Stationary / 200 Walking / 200 Running).

Training procedure

  • Optimizer: Adam (default learning rate)
  • Loss: sparse categorical crossentropy
  • Epochs: 6, batch size: 32
  • Same training configuration used across all four models in this lab, for a fair comparison

Evaluation results

Model Test Accuracy Parameters Train Time (s)
CNN 1.000 49,475 2.81
SimpleRNN 0.580 1,187 4.77
LSTM 0.693 4,451 7.12
CNN+LSTM (hybrid) 1.000 8,611 6.35

Limitations

  • Trained on a small, synthetic/fixed dataset — accuracy may not generalize to real-world wearable sensor data with more noise, sensor drift, or additional activity classes
  • Only 6 training epochs — SimpleRNN and LSTM in particular likely hadn't converged; their reported accuracy understates what they could achieve with more training
  • Fixed 100-step sequence length — not tested on longer or variable-length sequences

How to use

import tensorflow as tf
from tensorflow.keras import Sequential
from tensorflow.keras.layers import Conv1D, MaxPooling1D, Flatten, Dense

model = Sequential([
    Conv1D(32, kernel_size=5, activation="relu", input_shape=(100, 1)),
    MaxPooling1D(pool_size=2),
    Flatten(),
    Dense(32, activation="relu"),
    Dense(3, activation="softmax")
])
model.load_weights("activity_model.weights.h5")

# X: numpy array of shape (n_samples, 100, 1)
predictions = model.predict(X)

Authors

Group lab submission — [Group 6 - Iqra University Main Campus], CNN–RNN–LSTM Model Challenge, Beginner Deep Learning Group Lab.