Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random rotations Port #540

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions keras_core/layers/preprocessing/random_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from keras_core import backend
from keras_core.api_export import keras_core_export
from keras_core.layers.layer import Layer
from keras_core.random.seed_generator import SeedGenerator
from keras_core.utils import backend_utils
from keras_core.utils.module_utils import tensorflow as tf

Expand Down Expand Up @@ -84,16 +85,11 @@ def __init__(
seed=None,
fill_value=0.0,
name=None,
data_format=None,
**kwargs,
):
if not tf.available:
raise ImportError(
"Layer RandomRotation requires TensorFlow. "
"Install it via `pip install tensorflow`."
)

super().__init__(name=name, **kwargs)
self.seed = seed or backend.random.make_default_seed()
self.seed = SeedGenerator(seed)
self.layer = tf.keras.layers.RandomRotation(
factor=factor,
fill_mode=fill_mode,
Expand All @@ -103,6 +99,7 @@ def __init__(
name=name,
**kwargs,
)
self.data_format = backend.standardize_data_format(data_format)
self.supports_jit = False
self._convert_input_args = False
self._allow_non_tensor_positional_args = True
Expand All @@ -122,6 +119,11 @@ def compute_output_shape(self, input_shape):
return tuple(self.layer.compute_output_shape(input_shape))

def get_config(self):
config = self.layer.get_config()
config.update({"seed": self.seed})
config = super().get_config()
config.update(
{
"seed": self.seed,
"data_format": self.data_format,
}
)
return config
Loading