keras/keras_core/engine/layer_test.py
2023-04-09 12:21:45 -07:00

21 lines
619 B
Python

from keras_core import testing
from keras_core.engine import keras_tensor
from keras_core.engine.layer import Layer
import numpy as np
class FunctionTest(testing.TestCase):
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"):
SomeLayer()(x, True)
# This works
SomeLayer()(x, bool_arg=True)