Skip to content

Commit d3e55e8

Browse files
committed
denoise fix
1 parent df31dbc commit d3e55e8

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

python/09_convolutional_autoencoder.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,27 @@ def autoencoder(input_shape=[None, 784],
4646
x = tf.placeholder(
4747
tf.float32, input_shape, name='x')
4848

49-
# %%
50-
# Optionally apply denoising autoencoder
51-
if corruption:
52-
x_noise = corrupt(x)
53-
else:
54-
x_noise = x
5549

5650
# %%
5751
# ensure 2-d is converted to square tensor.
5852
if len(x.get_shape()) == 2:
59-
x_dim = np.sqrt(x_noise.get_shape().as_list()[1])
53+
x_dim = np.sqrt(x.get_shape().as_list()[1])
6054
if x_dim != int(x_dim):
6155
raise ValueError('Unsupported input dimensions')
6256
x_dim = int(x_dim)
6357
x_tensor = tf.reshape(
64-
x_noise, [-1, x_dim, x_dim, n_filters[0]])
65-
elif len(x_noise.get_shape()) == 4:
66-
x_tensor = x_noise
58+
x, [-1, x_dim, x_dim, n_filters[0]])
59+
elif len(x.get_shape()) == 4:
60+
x_tensor = x
6761
else:
6862
raise ValueError('Unsupported input dimensions')
6963
current_input = x_tensor
7064

65+
# %%
66+
# Optionally apply denoising autoencoder
67+
if corruption:
68+
current_input = corrupt(current_input)
69+
7170
# %%
7271
# Build the encoder
7372
encoder = []
-38.9 MB
Binary file not shown.
-43.7 MB
Binary file not shown.
-44 MB
Binary file not shown.

0 commit comments

Comments
 (0)