Skip to content

Commit 8c1970e

Browse files
Johannes Ballécopybara-github
authored andcommitted
Documentation tweaks.
PiperOrigin-RevId: 451898744 Change-Id: I10b1f0900fd578c00cc5f4062cc34e98cbffda19
1 parent 29b276e commit 8c1970e

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ docs](https://www.tensorflow.org/api_docs/python/tfc) for details):
3434
- Additional TensorFlow functions and Keras layers that are useful in the
3535
context of learned data compression, such as methods to numerically find
3636
quantiles of density functions, take expectations with respect to dithering
37-
noise, convolution layers with more flexible padding options, and an
37+
noise, convolution layers with more flexible padding options and support for
38+
reparameterizing kernels and biases in the Fourier domain, and an
3839
implementation of generalized divisive normalization (GDN).
3940

4041

tensorflow_compression/python/distributions/deep_factorized.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def _parameter_properties(cls, dtype=tf.float32, num_classes=None):
261261

262262

263263
class NoisyDeepFactorized(uniform_noise.UniformNoiseAdapter):
264-
"""DeepFactorized that is convolved with uniform noise."""
264+
"""`DeepFactorized` that is convolved with uniform noise."""
265265

266266
def __init__(self, name="NoisyDeepFactorized", **kwargs):
267267
super().__init__(DeepFactorized(**kwargs), name=name)

tensorflow_compression/python/distributions/round_adapters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def __init__(self, base, name="NoisyRoundAdapter"):
214214

215215

216216
class NoisyRoundedDeepFactorized(NoisyRoundAdapter):
217-
"""Rounded DeepFactorized + uniform noise."""
217+
"""Rounded `DeepFactorized` + uniform noise."""
218218

219219
def __init__(self, name="NoisyRoundedDeepFactorized", **kwargs):
220220
prior = deep_factorized.DeepFactorized(**kwargs)
@@ -276,7 +276,7 @@ def __init__(self, alpha=5.0, name="NoisySoftRoundedNormal", **kwargs):
276276

277277

278278
class NoisySoftRoundedDeepFactorized(NoisySoftRoundAdapter):
279-
"""Soft rounded deep factorized distribution + uniform noise."""
279+
"""Soft rounded `DeepFactorized` + uniform noise."""
280280

281281
def __init__(self,
282282
alpha=5.0,

tensorflow_compression/python/ops/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""Operations."""
15+
"""TensorFlow operations and functions."""
1616

1717
from tensorflow_compression.python.ops.gen_ops import *
1818
from tensorflow_compression.python.ops.math_ops import *

tensorflow_compression/python/ops/round_ops.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def round_st(inputs, offset=None):
4444

4545

4646
def soft_round(x, alpha, eps=1e-3):
47-
"""Differentiable approximation to round().
47+
"""Differentiable approximation to `round`.
4848
4949
Larger alphas correspond to closer approximations of the round function.
5050
If alpha is close to zero, this function reduces to the identity.
@@ -55,12 +55,12 @@ def soft_round(x, alpha, eps=1e-3):
5555
> https://arxiv.org/abs/2006.09952
5656
5757
Args:
58-
x: tf.Tensor. Inputs to the rounding function.
59-
alpha: Float or tf.Tensor. Controls smoothness of the approximation.
60-
eps: Float. Threshold below which soft_round() will return identity.
58+
x: `tf.Tensor`. Inputs to the rounding function.
59+
alpha: Float or `tf.Tensor`. Controls smoothness of the approximation.
60+
eps: Float. Threshold below which `soft_round` will return identity.
6161
6262
Returns:
63-
tf.Tensor
63+
`tf.Tensor`
6464
"""
6565
# This guards the gradient of tf.where below against NaNs, while maintaining
6666
# correctness, as for alpha < eps the result is ignored.
@@ -76,21 +76,21 @@ def soft_round(x, alpha, eps=1e-3):
7676

7777

7878
def soft_round_inverse(y, alpha, eps=1e-3):
79-
"""Inverse of soft_round().
79+
"""Inverse of `soft_round`.
8080
8181
This is described in Sec. 4.1. in the paper
8282
> "Universally Quantized Neural Compression"<br />
8383
> Eirikur Agustsson & Lucas Theis<br />
8484
> https://arxiv.org/abs/2006.09952
8585
8686
Args:
87-
y: tf.Tensor. Inputs to this function.
88-
alpha: Float or tf.Tensor. Controls smoothness of the approximation.
89-
eps: Float. Threshold below which soft_round() is assumed to equal the
87+
y: `tf.Tensor`. Inputs to this function.
88+
alpha: Float or `tf.Tensor`. Controls smoothness of the approximation.
89+
eps: Float. Threshold below which `soft_round` is assumed to equal the
9090
identity function.
9191
9292
Returns:
93-
tf.Tensor
93+
`tf.Tensor`
9494
"""
9595
# This guards the gradient of tf.where below against NaNs, while maintaining
9696
# correctness, as for alpha < eps the result is ignored.
@@ -108,11 +108,11 @@ def soft_round_inverse(y, alpha, eps=1e-3):
108108
return tf.where(alpha < eps, y, m + r, name="soft_round_inverse")
109109

110110

111-
def soft_round_conditional_mean(inputs, alpha):
111+
def soft_round_conditional_mean(y, alpha):
112112
"""Conditional mean of inputs given noisy soft rounded values.
113113
114114
Computes g(z) = E[Y | s(Y) + U = z] where s is the soft-rounding function,
115-
U is uniform between -0.5 and 0.5 and `Y` is considered uniform when truncated
115+
U is uniform between -0.5 and 0.5 and Y is considered uniform when truncated
116116
to the interval [z-0.5, z+0.5].
117117
118118
This is described in Sec. 4.1. in the paper
@@ -121,10 +121,10 @@ def soft_round_conditional_mean(inputs, alpha):
121121
> https://arxiv.org/abs/2006.09952
122122
123123
Args:
124-
inputs: The input tensor.
125-
alpha: The softround alpha.
124+
y: `tf.Tensor`. Inputs to this function.
125+
alpha: Float or `tf.Tensor`. Controls smoothness of the approximation.
126126
127127
Returns:
128128
The conditional mean, of same shape as `inputs`.
129129
"""
130-
return soft_round_inverse(inputs - .5, alpha) + .5
130+
return soft_round_inverse(y - .5, alpha) + .5

0 commit comments

Comments
 (0)