mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 06:23:20 -07:00
feat: use one-sided smoothing (eg: positive/real labels 1.0 -> 0.9), and only apply to discriminator
This commit is contained in:
parent
f3f2807972
commit
c36eca3610
1 changed files with 13 additions and 14 deletions
|
@ -551,29 +551,28 @@ Examples: df, liae, df-d, df-ud, liae-ud, ...
|
||||||
x = tf.random.categorical(probs, num_labels)
|
x = tf.random.categorical(probs, num_labels)
|
||||||
x = tf.cast(x, tf.float32)
|
x = tf.cast(x, tf.float32)
|
||||||
x = tf.math.scalar_mul(1-smoothing, x)
|
x = tf.math.scalar_mul(1-smoothing, x)
|
||||||
x = x + (smoothing/num_labels)
|
# x = x + (smoothing/num_labels)
|
||||||
x = tf.reshape(x, (self.batch_size,) + tensor.shape[1:])
|
x = tf.reshape(x, (self.batch_size,) + tensor.shape[1:])
|
||||||
return x
|
return x
|
||||||
|
|
||||||
smoothing = self.options['gan_smoothing']
|
smoothing = self.options['gan_smoothing']
|
||||||
noise = self.options['gan_noise']
|
noise = self.options['gan_noise']
|
||||||
|
|
||||||
gpu_pred_src_src_d_ones = get_smooth_noisy_labels(1, gpu_pred_src_src_d, smoothing=smoothing, noise=noise)
|
gpu_pred_src_src_d_ones = tf.ones_like(gpu_pred_src_src_d)
|
||||||
gpu_pred_src_src_d_zeros = get_smooth_noisy_labels(0, gpu_pred_src_src_d, smoothing=smoothing, noise=noise)
|
gpu_pred_src_src_d2_ones = tf.ones_like(gpu_pred_src_src_d2)
|
||||||
|
|
||||||
gpu_pred_src_src_d2_ones = get_smooth_noisy_labels(1, gpu_pred_src_src_d2, smoothing=smoothing, noise=noise)
|
gpu_pred_src_src_d_smooth_zeros = get_smooth_noisy_labels(0, gpu_pred_src_src_d, smoothing=smoothing, noise=noise)
|
||||||
gpu_pred_src_src_d2_zeros = get_smooth_noisy_labels(0, gpu_pred_src_src_d2, smoothing=smoothing, noise=noise)
|
gpu_pred_src_src_d2_smooth_zeros = get_smooth_noisy_labels(0, gpu_pred_src_src_d2, smoothing=smoothing, noise=noise)
|
||||||
|
|
||||||
gpu_target_src_d, \
|
gpu_target_src_d, gpu_target_src_d2 = self.D_src(gpu_target_src_masked_opt)
|
||||||
gpu_target_src_d2 = self.D_src(gpu_target_src_masked_opt)
|
|
||||||
|
|
||||||
gpu_target_src_d_ones = get_smooth_noisy_labels(1, gpu_target_src_d, smoothing=smoothing, noise=noise)
|
gpu_target_src_d_smooth_ones = get_smooth_noisy_labels(1, gpu_target_src_d, smoothing=smoothing, noise=noise)
|
||||||
gpu_target_src_d2_ones = get_smooth_noisy_labels(1, gpu_target_src_d2, smoothing=smoothing, noise=noise)
|
gpu_target_src_d2_smooth_ones = get_smooth_noisy_labels(1, gpu_target_src_d2, smoothing=smoothing, noise=noise)
|
||||||
|
|
||||||
gpu_D_src_dst_loss = (DLoss(gpu_target_src_d_ones , gpu_target_src_d) + \
|
gpu_D_src_dst_loss = DLoss(gpu_target_src_d_smooth_ones, gpu_target_src_d) \
|
||||||
DLoss(gpu_pred_src_src_d_zeros , gpu_pred_src_src_d) ) * 0.5 + \
|
+ DLoss(gpu_pred_src_src_d_smooth_zeros, gpu_pred_src_src_d) \
|
||||||
(DLoss(gpu_target_src_d2_ones , gpu_target_src_d2) + \
|
+ DLoss(gpu_target_src_d2_smooth_ones, gpu_target_src_d2) \
|
||||||
DLoss(gpu_pred_src_src_d2_zeros , gpu_pred_src_src_d2) ) * 0.5
|
+ DLoss(gpu_pred_src_src_d2_smooth_zeros, gpu_pred_src_src_d2)
|
||||||
|
|
||||||
gpu_D_src_dst_loss_gvs += [ nn.gradients (gpu_D_src_dst_loss, self.D_src.get_weights() ) ]#+self.D_src_x2.get_weights()
|
gpu_D_src_dst_loss_gvs += [ nn.gradients (gpu_D_src_dst_loss, self.D_src.get_weights() ) ]#+self.D_src_x2.get_weights()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue