| 33 | |
| 34 | |
| 35 | class LayerWithLosses(keras.layers.Layer): |
| 36 | |
| 37 | def build(self, input_shape): |
| 38 | self.v = self.add_weight( |
| 39 | name='hey', |
| 40 | shape=(), |
| 41 | initializer='ones', |
| 42 | regularizer=keras.regularizers.l1(100)) |
| 43 | |
| 44 | def call(self, inputs): |
| 45 | self.add_loss(math_ops.reduce_sum(inputs)) |
| 46 | return self.v * inputs |
| 47 | |
| 48 | |
| 49 | class LayerWithMetrics(keras.layers.Layer): |
no outgoing calls