File tree Expand file tree Collapse file tree 2 files changed +0
-17
lines changed
tensorflow_compression/python/layers Expand file tree Collapse file tree 2 files changed +0
-17
lines changed Original file line number Diff line number Diff line change 19
19
20
20
21
21
__all__ = [
22
- "Round" ,
23
22
"SoftRound" ,
24
23
"SoftRoundConditionalMean" ,
25
24
]
26
25
27
26
28
- class Round (tf .keras .layers .Layer ):
29
- """Applies rounding."""
30
-
31
- def call (self , inputs ):
32
- return tf .round (inputs )
33
-
34
- def compute_output_shape (self , input_shape ):
35
- return input_shape
36
-
37
-
38
27
class SoftRound (tf .keras .layers .Layer ):
39
28
"""Applies a differentiable approximation of rounding."""
40
29
Original file line number Diff line number Diff line change 21
21
22
22
class SoftRoundTest (tf .test .TestCase ):
23
23
24
- def test_round_layer_rounds (self ):
25
- layer = soft_round .Round ()
26
- x = tf .linspace (- 5.0 , 5.0 , num = 50 )
27
- y = layer (x )
28
- self .assertAllClose (y , tf .math .round (x ))
29
-
30
24
def test_soft_round_layer_soft_rounds (self ):
31
25
alpha = 5.0
32
26
layer = soft_round .SoftRound (alpha = alpha )
You can’t perform that action at this time.
0 commit comments