pkmital / CADL

ARCHIVED: Contains historical course materials/Homework materials for the FREE MOOC course on "Creative Applications of Deep Learning w/ Tensorflow" #CADL
https://www.kadenze.com/courses/creative-applications-of-deep-learning-with-tensorflow/info
Apache License 2.0
1.48k stars 732 forks source link

Noise ignored in denoising VAE #58

Closed sunsided closed 7 years ago

sunsided commented 7 years ago

This PR handles #56 by replacing

if denoising:
    current_input = utils.corrupt(x) * corrupt_prob + x * (1 - corrupt_prob)

# 2d -> 4d if convolution
x_tensor = utils.to_tensor(x) if convolutional else x
current_input = x_tensor

with

# apply noise if denoising
x_ = (utils.corrupt(x) * corrupt_prob + x * (1 - corrupt_prob)) if denoising else x

# 2d -> 4d if convolution
x_tensor = utils.to_tensor(x_) if convolutional else x_
current_input = x_tensor

The temporary x_ was introduced to keep the original input x intact for the loss function.

pkmital commented 7 years ago

Nice one! Thank you!