def test_activity_regularization(): layer = layers.ActivityRegularization(l1=0.01, l2=0.01) # test in functional API x = layers.Input(shape=(3,)) z = layers.Dense(2)(x) y = layer(z) model = Model(x, y) model.compile('rmsprop', 'mse') model.predict(np.random.random((2, 3))) # test serialization model_config = model.get_config() model = Model.from_config(model_config) model.compile('rmsprop', 'mse')
def test_activity_regularization(self): x = Normal(loc=tf.zeros([100, 10, 5]), scale=tf.ones([100, 10, 5])) y = layers.ActivityRegularization(l1=0.1)(x.value())
def __init__(self): super().__init__() self.loss_layer = layers.ActivityRegularization(l2=0.001) self.add_weight(shape=(1, ), regularizer="l2")
def __init__(self): super(LayerWithSharedNestedLossLayer, self).__init__() self.loss_layer = layers.ActivityRegularization(l2=0.001) self.add_weight(shape=(1,), regularizer='l2')
def test_activity_regularization(self): x = Normal(mu=tf.zeros([100, 10, 5]), sigma=tf.ones([100, 10, 5])) y = layers.ActivityRegularization(l1=0.1)(x)