Skip to content

Commit d156bbe

Browse files
author
Johannes Ballé
committed
Simplified imports and fixed gradients for likelihood lower bound.
1 parent bd546cf commit d156bbe

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tensorflow_compression/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323

2424
from tensorflow.python.util.all_util import remove_undocumented
2525

26-
# pylint: disable=wildcard-import,g-bad-import-order
27-
from tensorflow.contrib.coder.python.ops.coder_ops import *
26+
# pylint: disable=wildcard-import
2827
from tensorflow_compression.python.layers.entropy_models import *
2928
from tensorflow_compression.python.layers.gdn import *
3029
from tensorflow_compression.python.layers.initializers import *
3130
from tensorflow_compression.python.layers.parameterizers import *
3231
from tensorflow_compression.python.layers.signal import *
32+
from tensorflow_compression.python.ops.coder_ops import *
3333
from tensorflow_compression.python.ops.math_ops import *
3434
from tensorflow_compression.python.ops.padding_ops import *
3535
from tensorflow_compression.python.ops.spectral_ops import *
36-
# pylint: enable=wildcard-import,g-bad-import-order
36+
# pylint: enable=wildcard-import
3737

3838
remove_undocumented(__name__, [
3939
"EntropyBottleneck", "GDN", "IdentityInitializer", "Parameterizer",

tensorflow_compression/python/layers/entropy_models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
import numpy as np
2525

26-
from tensorflow.contrib.coder.python.ops import coder_ops
27-
2826
from tensorflow.python.eager import context
2927
from tensorflow.python.framework import constant_op
3028
from tensorflow.python.framework import dtypes
@@ -40,6 +38,9 @@
4038
from tensorflow.python.ops import state_ops
4139
from tensorflow.python.summary import summary
4240

41+
from tensorflow_compression.python.ops import coder_ops
42+
from tensorflow_compression.python.ops import math_ops as tfc_math_ops
43+
4344

4445
class EntropyBottleneck(base_layer.Layer):
4546
"""Entropy bottleneck layer.
@@ -436,8 +437,7 @@ def call(self, inputs, training):
436437
if self.likelihood_bound > 0:
437438
likelihood_bound = constant_op.constant(
438439
self.likelihood_bound, dtype=self.dtype)
439-
# TODO(jonycgn): Override gradients.
440-
likelihood = math_ops.maximum(likelihood, likelihood_bound)
440+
likelihood = tfc_math_ops.lower_bound(likelihood, likelihood_bound)
441441

442442
# Convert back to input tensor shape.
443443
order = list(range(1, ndim))

0 commit comments

Comments
 (0)