Skip to content

Commit

Permalink
Refactor code for speed and clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
UltralyticsAssistant committed Sep 5, 2024
1 parent c12011a commit f4d6349
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can run the WAVE models using the following scripts:

Explore the beauty of waveform signals and training process visualization with the images below:

![Waveform Signals](https://github.com/ultralytics/wave/blob/main/data/waveforms.png "Waveform signals captured by the detector.") ![Training Visualization](https://github.com/ultralytics/wave/blob/main/data/wave.png "Visualization of the training process.")
![Waveform Signals](https://github.com/ultralytics/wave/blob/main/data/waveforms.png%20%22Waveform%20signals%20captured%20by%20the%20detector.%22) ![Training Visualization](https://github.com/ultralytics/wave/blob/main/data/wave.png%20%22Visualization%20of%20the%20training%20process.%22)

# 📜 Citation

Expand All @@ -51,20 +51,20 @@ If you use this code in your research or wish to refer to the WAVE methodology,

# 🤝 Contribute

We value each contribution and invite you to participate in developing this pioneering ML approach for physics! Whether you're sharpening bugs, proposing new features, or enriching our documentation, find out how to contribute through our [Contributing Guide](https://docs.ultralytics.com/help/contributing). Also, let us know your thoughts by completing our [Survey](https://ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey). A massive thank you 🙏 to everyone involved!
We value each contribution and invite you to participate in developing this pioneering ML approach for physics! Whether you're sharpening bugs, proposing new features, or enriching our documentation, find out how to contribute through our [Contributing Guide](https://docs.ultralytics.com/help/contributing). Also, let us know your thoughts by completing our [Survey](https://www.ultralytics.com/survey?utm_source=github&utm_medium=social&utm_campaign=Survey). A massive thank you 🙏 to everyone involved!

![Ultralytics Open-Source Contributors](https://github.com/ultralytics/assets/raw/main/im/image-contributors.png "Thanks to our community of contributors!")
![Ultralytics Open-Source Contributors](https://github.com/ultralytics/assets/raw/main/im/image-contributors.png%20%22Thanks%20to%20our%20community%20of%20contributors!%22)

# 📄 License

Ultralytics is pleased to offer dual licensing options to accommodate a wide range of uses:

- **AGPL-3.0 License**: Our default [open-source license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE), which is OSI-approved and encourages open collaboration and knowledge sharing, is perfect for students, educators, and enthusiasts.
- **Enterprise License**: For commercial applications that require a more flexible licensing arrangement, our enterprise license allows integration of Ultralytics software into proprietary products and services. Reach out through [Ultralytics Licensing](https://ultralytics.com/license) for more details.
- **Enterprise License**: For commercial applications that require a more flexible licensing arrangement, our enterprise license allows integration of Ultralytics software into proprietary products and services. Reach out through [Ultralytics Licensing](https://www.ultralytics.com/license) for more details.

# 📬 Contact Us

For bug reports, feature requests, and contributions, head to [GitHub Issues](https://github.com/ultralytics/velocity/issues). For questions and discussions about this project and other Ultralytics endeavors, join us on [Discord](https://ultralytics.com/discord)!
For bug reports, feature requests, and contributions, head to [GitHub Issues](https://github.com/ultralytics/velocity/issues). For questions and discussions about this project and other Ultralytics endeavors, join us on [Discord](https://discord.com/invite/ultralytics)!

<br>
<div align="center">
Expand Down
2 changes: 2 additions & 0 deletions gcp/wave_pytorch_gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def runexample(H, model, str, lr=0.001, amsgrad=False):


class LinearAct(torch.nn.Module):
"""Applies a linear transformation followed by a Tanh activation to input tensors for neural network layers."""
def __init__(self, nx, ny):
"""Initializes the LinearAct module with input and output dimensions and defines a linear transformation
followed by a Tanh activation.
Expand All @@ -131,6 +132,7 @@ def forward(self, x):


class WAVE(torch.nn.Module):
"""A neural network model for processing waveform data using linear layers and activation functions."""
def __init__(self, n): # n = [512, 108, 23, 5, 1]
"""Initializes the WAVE model with specified linear layers and activation functions."""
super(WAVE, self).__init__()
Expand Down
4 changes: 4 additions & 0 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def train(H, model, str, lr=0.001):

# 400 5.1498e-05 0.023752 12.484 0.15728 # var 0
class WAVE(torch.nn.Module):
"""Implements a neural network model for waveform data processing using a multi-layer perceptron architecture."""
def __init__(self, n=(512, 64, 8, 2)):
"""Initializes the WAVE model architecture with specified layer sizes."""
super(WAVE, self).__init__()
Expand All @@ -139,6 +140,7 @@ def forward(self, x): # x.shape = [bs, 512]
# https://github.com/yunjey/pytorch-tutorial/tree/master/tutorials/02-intermediate
# 121 0.47059 0.0306 14.184 0.1608
class WAVE4(nn.Module):
"""Implements a convolutional neural network for waveform data processing with customizable output layers."""
def __init__(self, n_out=2):
"""Initializes the WAVE4 model with specified output layers and configurations for convolutional layers."""
super(WAVE4, self).__init__()
Expand Down Expand Up @@ -170,6 +172,7 @@ def forward(self, x): # x.shape = [bs, 512]

# 65 4.22e-05 0.021527 11.883 0.14406
class WAVE3(nn.Module):
"""WAVE3 implements a convolutional neural network for feature extraction and classification on waveform data."""
def __init__(self, n_out=2):
"""Initializes the WAVE3 class with neural network layers for feature extraction and classification in a
sequential manner.
Expand Down Expand Up @@ -215,6 +218,7 @@ def forward(self, x): # x.shape = [bs, 512]

# 121 2.6941e-05 0.021642 11.923 0.14201 # var 1
class WAVE2(nn.Module):
"""Implements a convolutional neural network for waveform data processing with configurable output dimensions."""
def __init__(self, n_out=2):
"""Initializes the WAVE2 model architecture components."""
super(WAVE2, self).__init__()
Expand Down
1 change: 1 addition & 0 deletions utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def model_info(model):


class patienceStopper(object):
"""Monitors training loss and metrics to halt early when no improvement is seen for a specified patience period."""
def __init__(self, patience=10, verbose=True, epochs=1000, printerval=10):
"""Initialize a patience stopper with given parameters for early stopping in training."""
self.patience = patience
Expand Down

0 comments on commit f4d6349

Please sign in to comment.