s3-timeseries


Names3-timeseries JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/shivam-grover/S3-TimeSeries
SummaryOfficial implementation of "Segment, Shuffle, and Stitch: A Simple Mechanism for Improving Time-Series Representations"
upload_time2024-10-26 06:33:05
maintainerNone
docs_urlNone
authorShivam Grover
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

[![PyPI version](https://badge.fury.io/py/S3.svg)](https://badge.fury.io/py/S3)
[![Arxiv](https://img.shields.io/static/v1?label=arXiv&message=2405.20082&color=B31B1B&logo=arXiv)](https://arxiv.org/abs/2405.20082)
[![NeurIPS](https://img.shields.io/static/v1?label=NeurIPS&message=Poster&color=B31B1B&logo=arXiv)](https://nips.cc/virtual/2024/poster/92935)
[![License: MIT](https://img.shields.io/badge/License-Apache%202.0-blue)](https://opensource.org/license/apache-2-0)

</div>

<h1 align="center">Segment, Shuffle, and Stitch: A Simple Layer for Improving Time-Series Representations</h1>
<h3 align="center">
Shivam Grover
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Amin Jalali
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Ali Etemad
</h3>
<h3 align="center">
NeurIPS 2024
</h3>
<h3 align="center"> 
<a href="https://arxiv.org/pdf/2405.20082">[Paper]</a>
</h3>

## Overview

S3 is a simple plug-and-play neural network component designed to enhance time-series representation learning. S3 works by segmenting the input time-series, shuffling the segments in a learned, task-specific manner, and stitching the shuffled segments back together. S3 is modular and can be stacked to create varying degrees of granularity, integrating seamlessly with many neural architectures (e.g., CNNs, Transformers) with minimal computational overhead. It has shown improvements in both time-series classification and forecasting tasks.

## Key Features

- **Segment-Shuffle-Stitch**: Segment the input time-series, shuffle segments based on learned parameters, and stitch them back together with the original sequence for enhanced learning.
- **Easy to use**: With just 2 lines of code, you can integrate multiple S3 layers into your model.
- **Lightweight**: S3 adds minimal computational overhead to existing models.
- **Versatile**: Integrates easily with various types of models, including CNNs, Transformers, and others.

## Installation

You can install S3 via PyPI:

```bash
pip install s3-timeseries
```

Or install from the source:

```bash
git clone https://github.com/shivam-grover/S3-TimeSeries.git
cd S3
pip install .
```

## Usage
Here's how to incorporate S3 into your PyTorch model:
```python
import torch
from S3 import S3

# Sample input: batch_size = 32, time_steps = 96, features = 9
x = torch.randn(32, 96, 9)

# Initialize S3 with your desired configuration
s3_layers = S3(num_layers=3, initial_num_segments=4, shuffle_vector_dim=1, segment_multiplier=2)

# Apply the S3 layer
output = s3_layers(x)
```

### Arguments for `S3`

| **Parameter**          | **Explanation**                                                                                         | **Range / Sample Values**                       |
|------------------------|---------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| `num_layers`           | Number of S3 layers to stack.                                                                            | Positive integer (e.g., 1, 2, 3)                   |
| `initial_num_segments`  | Number of segments in the first layer. This will be used only if `segments_per_layer` is not provided.   | Positive integer (e.g., 4, 8, 16)                   |
| `segment_multiplier`    | Multiplier for the number of segments in each consecutive layer.                                        | Positive float or integer (e.g., 0.5, 1, 2)        |
| `shuffle_vector_dim`    | Dimensionality of the shuffle vector, controlling shuffle complexity.                                   | Positive integer (e.g., 1, 2, 3)                |
| `use_conv_w_avg`        | Whether to use convolution-based weighted averaging.                                                    | `True`, `False`                                 |
| `initialization_type`   | **Optional**. Initialization type for shuffle vectors, such as "kaiming" or "manual".                                 | `"kaiming"`, `"manual"`                         |
| `use_stitch`            | **Optional**. Whether to use stitching to combine shuffled and original sequences.                                    | `True`, `False`                                 |
| `segments_per_layer`    | **TODO**. An array specifying the exact number of segments for each layer. Overrides `initial_num_segments` and `segment_multiplier`. | List of integers (e.g., [4, 8, 16])             |

## Citation
If you find this repository useful, please consider giving a star and citing it using the given BibTeX entry:
```bibtex
@inproceedings{
      S3TimeSeries,
      title={Segment, Shuffle, and Stitch: A Simple Layer for Improving Time-Series Representations},
      author={Shivam Grover, Amin Jalali, Ali Etemad},
      booktitle={Neural Information Processing Systems (NeurIPS)},
      year={2024},
      url={https://arxiv.org/pdf/2405.20082}
}
```

## Contact
Please contact me at <shivam.grover@queensu.ca> or connect with me on [LinkedIn](https://www.linkedin.com/in/shivam-grover/).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/shivam-grover/S3-TimeSeries",
    "name": "s3-timeseries",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Shivam Grover",
    "author_email": "shivam.grover@queensu.com",
    "download_url": "https://files.pythonhosted.org/packages/94/2b/85635cc17568a369ae58957699292f30f9fc6b36a24eba152a8c9bb08fbc/s3_timeseries-0.1.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n[![PyPI version](https://badge.fury.io/py/S3.svg)](https://badge.fury.io/py/S3)\n[![Arxiv](https://img.shields.io/static/v1?label=arXiv&message=2405.20082&color=B31B1B&logo=arXiv)](https://arxiv.org/abs/2405.20082)\n[![NeurIPS](https://img.shields.io/static/v1?label=NeurIPS&message=Poster&color=B31B1B&logo=arXiv)](https://nips.cc/virtual/2024/poster/92935)\n[![License: MIT](https://img.shields.io/badge/License-Apache%202.0-blue)](https://opensource.org/license/apache-2-0)\n\n</div>\n\n<h1 align=\"center\">Segment, Shuffle, and Stitch: A Simple Layer for Improving Time-Series Representations</h1>\n<h3 align=\"center\">\nShivam Grover\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nAmin Jalali\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nAli Etemad\n</h3>\n<h3 align=\"center\">\nNeurIPS 2024\n</h3>\n<h3 align=\"center\"> \n<a href=\"https://arxiv.org/pdf/2405.20082\">[Paper]</a>\n</h3>\n\n## Overview\n\nS3 is a simple plug-and-play neural network component designed to enhance time-series representation learning. S3 works by segmenting the input time-series, shuffling the segments in a learned, task-specific manner, and stitching the shuffled segments back together. S3 is modular and can be stacked to create varying degrees of granularity, integrating seamlessly with many neural architectures (e.g., CNNs, Transformers) with minimal computational overhead. It has shown improvements in both time-series classification and forecasting tasks.\n\n## Key Features\n\n- **Segment-Shuffle-Stitch**: Segment the input time-series, shuffle segments based on learned parameters, and stitch them back together with the original sequence for enhanced learning.\n- **Easy to use**: With just 2 lines of code, you can integrate multiple S3 layers into your model.\n- **Lightweight**: S3 adds minimal computational overhead to existing models.\n- **Versatile**: Integrates easily with various types of models, including CNNs, Transformers, and others.\n\n## Installation\n\nYou can install S3 via PyPI:\n\n```bash\npip install s3-timeseries\n```\n\nOr install from the source:\n\n```bash\ngit clone https://github.com/shivam-grover/S3-TimeSeries.git\ncd S3\npip install .\n```\n\n## Usage\nHere's how to incorporate S3 into your PyTorch model:\n```python\nimport torch\nfrom S3 import S3\n\n# Sample input: batch_size = 32, time_steps = 96, features = 9\nx = torch.randn(32, 96, 9)\n\n# Initialize S3 with your desired configuration\ns3_layers = S3(num_layers=3, initial_num_segments=4, shuffle_vector_dim=1, segment_multiplier=2)\n\n# Apply the S3 layer\noutput = s3_layers(x)\n```\n\n### Arguments for `S3`\n\n| **Parameter**          | **Explanation**                                                                                         | **Range / Sample Values**                       |\n|------------------------|---------------------------------------------------------------------------------------------------------|-------------------------------------------------|\n| `num_layers`           | Number of S3 layers to stack.                                                                            | Positive integer (e.g., 1, 2, 3)                   |\n| `initial_num_segments`  | Number of segments in the first layer. This will be used only if `segments_per_layer` is not provided.   | Positive integer (e.g., 4, 8, 16)                   |\n| `segment_multiplier`    | Multiplier for the number of segments in each consecutive layer.                                        | Positive float or integer (e.g., 0.5, 1, 2)        |\n| `shuffle_vector_dim`    | Dimensionality of the shuffle vector, controlling shuffle complexity.                                   | Positive integer (e.g., 1, 2, 3)                |\n| `use_conv_w_avg`        | Whether to use convolution-based weighted averaging.                                                    | `True`, `False`                                 |\n| `initialization_type`   | **Optional**. Initialization type for shuffle vectors, such as \"kaiming\" or \"manual\".                                 | `\"kaiming\"`, `\"manual\"`                         |\n| `use_stitch`            | **Optional**. Whether to use stitching to combine shuffled and original sequences.                                    | `True`, `False`                                 |\n| `segments_per_layer`    | **TODO**. An array specifying the exact number of segments for each layer. Overrides `initial_num_segments` and `segment_multiplier`. | List of integers (e.g., [4, 8, 16])             |\n\n## Citation\nIf you find this repository useful, please consider giving a star and citing it using the given BibTeX entry:\n```bibtex\n@inproceedings{\n      S3TimeSeries,\n      title={Segment, Shuffle, and Stitch: A Simple Layer for Improving Time-Series Representations},\n      author={Shivam Grover, Amin Jalali, Ali Etemad},\n      booktitle={Neural Information Processing Systems (NeurIPS)},\n      year={2024},\n      url={https://arxiv.org/pdf/2405.20082}\n}\n```\n\n## Contact\nPlease contact me at <shivam.grover@queensu.ca> or connect with me on [LinkedIn](https://www.linkedin.com/in/shivam-grover/).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Official implementation of \"Segment, Shuffle, and Stitch: A Simple Mechanism for Improving Time-Series Representations\"",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/shivam-grover/S3-TimeSeries"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee49b5398af68acea67e7b058b6f4f3cc72d7f7a2062e2049ebd8dd32715c5d6",
                "md5": "1f29cb9869f4022308411a5b224ad7dc",
                "sha256": "274dbb51f0483bd0dd0f362bcb4620ae97f15fd56c6e0644b6dbd498a7d00fa6"
            },
            "downloads": -1,
            "filename": "s3_timeseries-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1f29cb9869f4022308411a5b224ad7dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 11978,
            "upload_time": "2024-10-26T06:33:03",
            "upload_time_iso_8601": "2024-10-26T06:33:03.904133Z",
            "url": "https://files.pythonhosted.org/packages/ee/49/b5398af68acea67e7b058b6f4f3cc72d7f7a2062e2049ebd8dd32715c5d6/s3_timeseries-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "942b85635cc17568a369ae58957699292f30f9fc6b36a24eba152a8c9bb08fbc",
                "md5": "ae43e3595b6caa7a4c3f85c896126080",
                "sha256": "f1433f5d0da3f6a409860430a9c32c794761c78a9bf736462945b0f20f0959f3"
            },
            "downloads": -1,
            "filename": "s3_timeseries-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ae43e3595b6caa7a4c3f85c896126080",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12420,
            "upload_time": "2024-10-26T06:33:05",
            "upload_time_iso_8601": "2024-10-26T06:33:05.475149Z",
            "url": "https://files.pythonhosted.org/packages/94/2b/85635cc17568a369ae58957699292f30f9fc6b36a24eba152a8c9bb08fbc/s3_timeseries-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-26 06:33:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shivam-grover",
    "github_project": "S3-TimeSeries",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "s3-timeseries"
}
        
Elapsed time: 1.59850s