keras/keras_core/layers/layer_test.py

24 lines
640 B
Python
Raw Normal View History

import numpy as np
2023-04-09 19:21:45 +00:00
from keras_core import testing
2023-04-12 21:27:30 +00:00
from keras_core.backend import keras_tensor
2023-04-09 19:35:32 +00:00
from keras_core.layers.layer import Layer
2023-04-09 19:21:45 +00:00
2023-04-16 01:51:10 +00:00
class LayerTest(testing.TestCase):
2023-04-09 19:21:45 +00:00
def test_positional_arg_error(self):
class SomeLayer(Layer):
def call(self, x, bool_arg):
if bool_arg:
return x
return x + 1
x = keras_tensor.KerasTensor(shape=(2, 3), name="x")
with self.assertRaisesRegex(
ValueError, "Only input tensors may be passed as"
):
2023-04-09 19:21:45 +00:00
SomeLayer()(x, True)
# This works
SomeLayer()(x, bool_arg=True)