24 lines
640 B
Python
24 lines
640 B
Python
import numpy as np
|
|
|
|
from keras_core import testing
|
|
from keras_core.backend import keras_tensor
|
|
from keras_core.layers.layer import Layer
|
|
|
|
|
|
class LayerTest(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)
|