tfl.lattice_lib.laplacian_regularizer
Stay organized with collections
Save and categorize content based on your preferences.
Returns Laplacian regularization loss for Lattice
layer.
tfl.lattice_lib.laplacian_regularizer(
weights, lattice_sizes, l1=0.0, l2=0.0
)
Laplacian regularizer penalizes the difference between adjacent vertices in
multi-cell lattice (see
publication).
Consider a 3 x 2 lattice with weights w
:
w[3]-----w[4]-----w[5]
| | |
| | |
w[0]-----w[1]-----w[2]
where the number at each node represents the weight index.
In this case, the laplacian regularizer is defined as:
l1[0] * (|w[1] - w[0]| + |w[2] - w[1]| +
|w[4] - w[3]| + |w[5] - w[4]|) +
l1[1] * (|w[3] - w[0]| + |w[4] - w[1]| + |w[5] - w[2]|) +
l2[0] * ((w[1] - w[0])^2 + (w[2] - w[1])^2 +
(w[4] - w[3])^2 + (w[5] - w[4])^2) +
l2[1] * ((w[3] - w[0])^2 + (w[4] - w[1])^2 + (w[5] - w[2])^2)
Arguments |
weights
|
Lattice weights tensor of shape: (prod(lattice_sizes), units) .
|
lattice_sizes
|
List or tuple of integers which represents lattice sizes.
|
l1
|
l1 regularization amount. Either single float or list or tuple of floats
to specify different regularization amount per dimension.
|
l2
|
l2 regularization amount. Either single float or list or tuple of floats
to specify different regularization amount per dimension.
|
Returns |
Laplacian regularization loss.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-02 UTC.
[null,null,["Last updated 2024-08-02 UTC."],[],[],null,["# tfl.lattice_lib.laplacian_regularizer\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/lattice/blob/v2.1.1/tensorflow_lattice/python/lattice_lib.py#L2074-L2154) |\n\nReturns Laplacian regularization loss for `Lattice` layer. \n\n tfl.lattice_lib.laplacian_regularizer(\n weights, lattice_sizes, l1=0.0, l2=0.0\n )\n\nLaplacian regularizer penalizes the difference between adjacent vertices in\nmulti-cell lattice (see\n[publication](http://jmlr.org/papers/v17/15-243.html)).\n\nConsider a 3 x 2 lattice with weights `w`: \n\n w[3]-----w[4]-----w[5]\n | | |\n | | |\n w[0]-----w[1]-----w[2]\n\nwhere the number at each node represents the weight index.\nIn this case, the laplacian regularizer is defined as: \n\n l1[0] * (|w[1] - w[0]| + |w[2] - w[1]| +\n |w[4] - w[3]| + |w[5] - w[4]|) +\n l1[1] * (|w[3] - w[0]| + |w[4] - w[1]| + |w[5] - w[2]|) +\n\n l2[0] * ((w[1] - w[0])^2 + (w[2] - w[1])^2 +\n (w[4] - w[3])^2 + (w[5] - w[4])^2) +\n l2[1] * ((w[3] - w[0])^2 + (w[4] - w[1])^2 + (w[5] - w[2])^2)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments --------- ||\n|-----------------|------------------------------------------------------------------------------------------------------------------------------------|\n| `weights` | `Lattice` weights tensor of shape: `(prod(lattice_sizes), units)`. |\n| `lattice_sizes` | List or tuple of integers which represents lattice sizes. |\n| `l1` | l1 regularization amount. Either single float or list or tuple of floats to specify different regularization amount per dimension. |\n| `l2` | l2 regularization amount. Either single float or list or tuple of floats to specify different regularization amount per dimension. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Laplacian regularization loss. ||\n\n\u003cbr /\u003e"]]