Skip to content

Commit

Permalink
Merge pull request #56 from cyber-physical-systems-group/reorganize
Browse files Browse the repository at this point in the history
Reorganize
  • Loading branch information
kzajac97 authored Jan 3, 2025
2 parents 829416f + 8d57ae7 commit 99725e2
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 264 deletions.
4 changes: 0 additions & 4 deletions pydentification/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from .process import decay, unbatch
from .sequences import generate_time_series_windows
from .splits import compute_n_validation_samples, draw_validation_indices, time_series_train_test_split

__all__ = [
# torch utils
"decay",
"unbatch",
# windowing utils
"generate_time_series_windows",
# train-test-validation splitting utils
Expand Down
32 changes: 0 additions & 32 deletions pydentification/data/process.py

This file was deleted.

1 change: 0 additions & 1 deletion pydentification/models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ stacking.
This package contains following submodules:
* `modules` - building blocks of the models, extending PyTorch modules with custom layers, activation functions, etc.
* `networks` - models composed of building blocks, such as transformer etc.
* `nonparametric` - non-parametric models and supporting utils
Empty file.
6 changes: 2 additions & 4 deletions pydentification/models/modules/activations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from .functional import bounded_linear_unit, universal_activation
from .modules import BoundedLinearUnit, UniversalActivation
from .functional import universal_activation
from .modules import UniversalActivation

__all__ = [
"bounded_linear_unit",
"BoundedLinearUnit",
"universal_activation",
"UniversalActivation",
]
9 changes: 0 additions & 9 deletions pydentification/models/modules/activations/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
from torch import Tensor


def bounded_linear_unit(inputs: Tensor, lower: float | Tensor, upper: float | Tensor, inplace: bool = False) -> Tensor:
"""
Bounded linear activation function. It means that the output is linear in range [lower, upper] and clamped
outside of it to the values of the bounds. Bounds can be scalar of tensor of the same shape as inputs.
"""
out = inputs if inplace else None
return torch.clamp(inputs, min=lower, max=upper, out=out)


def universal_activation(inputs: Tensor, inplace: bool = False) -> Tensor:
"""
Universal activation function, for which finite number of neurons can approximate any continuous function on
Expand Down
27 changes: 0 additions & 27 deletions pydentification/models/modules/activations/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,6 @@
from . import functional as func


class BoundedLinearUnit(Module):
"""
Bounded linear activation function. It means that the output is linear in range [-bounds, bounds] and clamped
outside of it to the values of the bounds. Bounds can be scalar of tensor of the same shape as inputs.
"""

def __init__(
self,
lower: float | Tensor | None = None,
upper: float | Tensor | None = None,
):
"""
Bounds given in __init__ are static, applied irrespective of the input bounds
they can be scalar or tensor of the same shape as inputs
"""
super(BoundedLinearUnit, self).__init__()

self.static_lower_bound = lower
self.static_upper_bound = upper

def forward(self, inputs: Tensor, bounds: float | Tensor | None = None) -> Tensor:
lower = bounds if self.static_lower_bound is None else self.static_lower_bound
upper = bounds if self.static_upper_bound is None else self.static_upper_bound

return func.bounded_linear_unit(inputs, lower=lower, upper=upper)


class UniversalActivation(Module):
"""
Universal activation function, for which finite number of neurons can approximate any continuous function on
Expand Down
1 change: 0 additions & 1 deletion pydentification/models/modules/losses/__init__.py

This file was deleted.

35 changes: 0 additions & 35 deletions pydentification/models/modules/losses/modules.py

This file was deleted.

2 changes: 1 addition & 1 deletion pydentification/models/networks/transformer/feedforward.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def forward(self, inputs: Tensor) -> Tensor:
class CausalDelayLineFeedforward(nn.Module):
"""
Linear transformation of the input signal using delay line with casual mask, allowing only connections from future
to past time steps, which means single row of weight matrix is multiplied with each time step of the input signal.
to past-time steps, which means single row of weight matrix is multiplied with each time step of the input signal.
For MIMO systems, different weight matrix is applied for each dimension, where each of the matrices is stored in
MaskedLinear module in torch.nn.ModuleList.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include = ["pydentification*"]

[project]
name = "pydentification"
version = "0.4.1"
version = "0.5.0"
description = "Toolbox for dynamical system identification with neural networks"
license = {text = "MIT"}
readme = {file = "README.md", content-type = "text/markdown"}
Expand Down
57 changes: 0 additions & 57 deletions tests/test_data/test_process.py

This file was deleted.

34 changes: 0 additions & 34 deletions tests/test_models/test_losses.py

This file was deleted.

58 changes: 0 additions & 58 deletions tests/test_models/test_modules/test_activation.py

This file was deleted.

0 comments on commit 99725e2

Please sign in to comment.