Skip to content

Commit

Permalink
Merge pull request #11 from sascha-kirch/document_models
Browse files Browse the repository at this point in the history
Document models
  • Loading branch information
sascha-kirch authored Oct 20, 2023
2 parents b066b36 + 7cc7505 commit d561a2c
Show file tree
Hide file tree
Showing 25 changed files with 977 additions and 628 deletions.
8 changes: 4 additions & 4 deletions DeepSaki/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from . import constraints
from . import initializers
from . import layers
from . import loss
from . import losses
from . import models
from . import optimizer
from . import optimizers
from . import utils

__version__ = "1.0.0"
Expand All @@ -18,8 +18,8 @@
"constraints",
"initializers",
"layers",
"loss",
"losses",
"models",
"optimizer",
"optimizers",
"utils",
]
4 changes: 2 additions & 2 deletions DeepSaki/activations/complex_valued_activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class ComplexActivation(tf.keras.layers.Layer):
tf.keras.layers.Layer
"""

def __init__(self, activation: tf.keras.layers.Layer = tf.keras.layers.ReLU(), **kwargs: Any) -> None:
def __init__(self, activation: tf.keras.layers.Layer, **kwargs: Any) -> None:
"""Initialize ComplexActivation.
Args:
activation (tf.keras.layers.Layer, optional): Activation function to complexyfy. Defaults to tf.keras.layers.ReLU().
activation (tf.keras.layers.Layer): Activation function to complexyfy.
kwargs: keyword arguments passed to the parent class tf.keras.layers.Layer.
"""
super(ComplexActivation, self).__init__(**kwargs)
Expand Down
7 changes: 4 additions & 3 deletions DeepSaki/augmentations/grid_cutting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ def _random_boundingbox(height: int, width: int) -> Tuple[int, int, int, int]:
x value bottom-right corner.
y value bottom-right corner.
"""
r = np.sqrt(1.0 - np.random.beta(1, 1))
random_generator = np.random.default_rng()
r = np.sqrt(1.0 - random_generator.beta(1, 1))
w = np.floor(width * r)
h = np.floor(height * r)
x = np.random.randint(width)
y = np.random.randint(height)
x = random_generator.integers(width)
y = random_generator.integers(height)

x1 = int(np.clip(x - w // 2, 0, width))
y1 = int(np.clip(y - h // 2, 0, height))
Expand Down
2 changes: 1 addition & 1 deletion DeepSaki/initializers/he_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, alpha: float = 0.3, seed: Optional[int] = None) -> None:
"""
super(HeAlphaUniform, self).__init__(alpha, seed)

def __call__(self, shape: List[int], dtype: Optional[Union[tf.DType | np.dtype]] = None) -> tf.Tensor:
def __call__(self, shape: List[int], dtype: Optional[Union[tf.DType, np.dtype]] = None) -> tf.Tensor:
"""Dunder method to call the object instance.
Args:
Expand Down
6 changes: 4 additions & 2 deletions DeepSaki/initializers/initializer_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ def make_initializer_complex(
**Examples:**
```python
# Standalone usage:
initializer = make_initializer_complex(tf.keras.initializers.GlorotUniform())
import DeepSaki as dsk
initializer = dsk.initializers.make_initializer_complex(tf.keras.initializers.GlorotUniform())
values = initializer(shape=(2, 2))
```
```python
# Usage in a Keras layer:
initializer = make_initializer_complex(tf.keras.initializers.GlorotUniform())
import DeepSaki as dsk
initializer = dsk.initializers.make_initializer_complex(tf.keras.initializers.GlorotUniform())
layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)
```
Expand Down
2 changes: 1 addition & 1 deletion DeepSaki/layers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from DeepSaki.layers.layer_composites import DenseBlock
from DeepSaki.layers.layer_composites import DownSampleBlock
from DeepSaki.layers.layer_composites import UpSampleBlock
from DeepSaki.layers.layer_composites import ResidualIdentityBlock
from DeepSaki.layers.layer_composites import ResidualBlock
from DeepSaki.layers.layer_composites import ResBlockDown
from DeepSaki.layers.layer_composites import ResBlockUp
from DeepSaki.layers.layer_composites import ScaleLayer
Expand Down
Loading

0 comments on commit d561a2c

Please sign in to comment.