Easy way to clamp Neural Network outputs between 0 and 1?
问题 So I'm working on writing a GAN neural network and I want to set my network's output to 0 if it is less than 0 and 1 if it is greater than 1 and leave it unchanged otherwise. I'm pretty new to tensorflow, but I don't know of any tensorflow function or activation to do this without unwanted side effects. So I made my loss function so it calculates the loss as if the output was clamped, with this code: def discriminator_loss(real_output, fake_output): real_output_clipped = min(max(real_output