Instructions to use hamzaN1/CNN-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use hamzaN1/CNN-Model with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://hamzaN1/CNN-Model") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from hamzaN1/CNN-Model: direct link, hf CLI and curl.
- Browser
- Download file 2.74 kB
-
https://huggingface.co/hamzaN1/CNN-Model/resolve/main/README.md
- Command line
-
hf download hf://hamzaN1/CNN-Model/README.md
-
curl -L -o README.md https://huggingface.co/hamzaN1/CNN-Model/resolve/main/README.md
2.74 kB
| 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 | |
| ```python | |
| 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. | |