|
22 | 22 | https://arxiv.org/abs/1611.01704 |
23 | 23 |
|
24 | 24 | With patches from Victor Xing <victor.t.xing@gmail.com> |
| 25 | +
|
| 26 | +This is meant as 'educational' code - you can use this to get started with your |
| 27 | +own experiments. To reproduce the exact results from the paper, tuning of hyper- |
| 28 | +parameters may be necessary. To compress images with published models, see |
| 29 | +`tfci.py`. |
25 | 30 | """ |
26 | 31 |
|
27 | 32 | from __future__ import absolute_import |
@@ -176,11 +181,11 @@ def build(self, input_shape): |
176 | 181 | tfc.SignalConv2D( |
177 | 182 | self.num_filters, (5, 5), name="layer_0", corr=False, strides_up=2, |
178 | 183 | padding="same_zeros", use_bias=True, |
179 | | - activation=tfc.GDN(name="gdn_0", inverse=True)), |
| 184 | + activation=tfc.GDN(name="igdn_0", inverse=True)), |
180 | 185 | tfc.SignalConv2D( |
181 | 186 | self.num_filters, (5, 5), name="layer_1", corr=False, strides_up=2, |
182 | 187 | padding="same_zeros", use_bias=True, |
183 | | - activation=tfc.GDN(name="gdn_1", inverse=True)), |
| 188 | + activation=tfc.GDN(name="igdn_1", inverse=True)), |
184 | 189 | tfc.SignalConv2D( |
185 | 190 | 3, (9, 9), name="layer_2", corr=False, strides_up=4, |
186 | 191 | padding="same_zeros", use_bias=True, |
@@ -290,7 +295,7 @@ def compress(args): |
290 | 295 | y_hat, likelihoods = entropy_bottleneck(y, training=False) |
291 | 296 | x_hat = synthesis_transform(y_hat) |
292 | 297 |
|
293 | | - num_pixels = tf.to_float(tf.reduce_prod(tf.shape(x)[:-1])) |
| 298 | + num_pixels = tf.cast(tf.reduce_prod(tf.shape(x)[:-1]), dtype=tf.float32) |
294 | 299 |
|
295 | 300 | # Total number of bits divided by number of pixels. |
296 | 301 | eval_bpp = tf.reduce_sum(tf.log(likelihoods)) / (-np.log(2) * num_pixels) |
|
0 commit comments