# Path: reservoir_nn/local_learning/learning.py
# class LearningRuleName(enum.Enum):
# class LocalLearning(tf.keras.layers.Layer):
#   NONE = 'none'
#   HEBBIAN = 'hebbian'
#   OJA = 'oja'
#   CONTRASTIVEHEBBIAN = 'contrastive_hebbian'
#   def __init__(self, learning_rule: str = 'none', **kwargs):
#   def call(
#       self,
#       learning_params: Dict[str, Any],
#       activation: types.TensorLike,
#       weight: types.TensorLike,
#       expected: Optional[types.TensorLike] = None
#   ) -> Union[types.TensorLike, None]:
#   def hebbian_learning(self,
#                        activation: types.TensorLike,
#                        weight: types.TensorLike,
#                        eta: float = 0.1) -> types.TensorLike:
#   def oja_learning(self,
#                    activation: types.TensorLike,
#                    weight: types.TensorLike,
#                    eta: float = 0.1) -> types.TensorLike:
#   def contrastive_hebbian_learning(self,
#                                    activation: types.TensorLike,
#                                    weight: types.TensorLike,
#                                    expected: types.TensorLike,
#                                    eta: float = 0.1,
#                                    gamma: float = 0.1,
#                                    max_iter: int = 10) -> types.TensorLike:


from absl.testing import absltest
from reservoir_nn.local_learning import learning
import numpy as np
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for local learning."""




class LearningTest(absltest.TestCase):

  def test_hebbian_learning_works(self):
    batch_size = 10
    hidden_size = 20
    activation = np.random.random((batch_size, hidden_size))
    weight = np.random.random((hidden_size, hidden_size))
    params = {'eta': 0.1}

# Path: reservoir_nn/local_learning/learning.py
# class LearningRuleName(enum.Enum):
# class LocalLearning(tf.keras.layers.Layer):
#   NONE = 'none'
#   HEBBIAN = 'hebbian'
#   OJA = 'oja'
#   CONTRASTIVEHEBBIAN = 'contrastive_hebbian'
#   def __init__(self, learning_rule: str = 'none', **kwargs):
#   def call(
#       self,
#       learning_params: Dict[str, Any],
#       activation: types.TensorLike,
#       weight: types.TensorLike,
#       expected: Optional[types.TensorLike] = None
#   ) -> Union[types.TensorLike, None]:
#   def hebbian_learning(self,
#                        activation: types.TensorLike,
#                        weight: types.TensorLike,
#                        eta: float = 0.1) -> types.TensorLike:
#   def oja_learning(self,
#                    activation: types.TensorLike,
#                    weight: types.TensorLike,
#                    eta: float = 0.1) -> types.TensorLike:
#   def contrastive_hebbian_learning(self,
#                                    activation: types.TensorLike,
#                                    weight: types.TensorLike,
#                                    expected: types.TensorLike,
#                                    eta: float = 0.1,
#                                    gamma: float = 0.1,
#                                    max_iter: int = 10) -> types.TensorLike:


# Path: reservoir_nn/local_learning/learning_test.py
from absl.testing import absltest
from reservoir_nn.local_learning import learning
import numpy as np

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for local learning."""




class LearningTest(absltest.TestCase):

  def test_hebbian_learning_works(self):
    batch_size = 10
    hidden_size = 20
    activation = np.random.random((batch_size, hidden_size))
    weight = np.random.random((hidden_size, hidden_size))
    params = {'eta': 0.1}

    new_weight = learning.LocalLearning(learning_rule='hebbian')(params,