mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-08-22 06:23:20 -07:00
assign device
This commit is contained in:
parent
6c42cd3a8f
commit
beb8c30970
1 changed files with 11 additions and 2 deletions
|
@ -19,7 +19,16 @@ class MsSsim(nn.LayerBase):
|
||||||
# Transpose images from NCHW to NHWC
|
# Transpose images from NCHW to NHWC
|
||||||
y_true_t = tf.transpose(tf.cast(y_true, tf.float32), [0, 2, 3, 1])
|
y_true_t = tf.transpose(tf.cast(y_true, tf.float32), [0, 2, 3, 1])
|
||||||
y_pred_t = tf.transpose(tf.cast(y_pred, tf.float32), [0, 2, 3, 1])
|
y_pred_t = tf.transpose(tf.cast(y_pred, tf.float32), [0, 2, 3, 1])
|
||||||
loss = tf.image.ssim_multiscale(y_true_t, y_pred_t, max_val, power_factors=self.power_factors)
|
|
||||||
return (1.0 - loss) / 2.0
|
|
||||||
|
def assign_device(op):
|
||||||
|
if op.type != 'Assert':
|
||||||
|
return '/gpu:0'
|
||||||
|
else:
|
||||||
|
return '/cpu:0'
|
||||||
|
|
||||||
|
with tf.device(assign_device):
|
||||||
|
loss = tf.image.ssim_multiscale(y_true_t, y_pred_t, max_val, power_factors=self.power_factors)
|
||||||
|
return (1.0 - loss) / 2.0
|
||||||
|
|
||||||
nn.MsSsim = MsSsim
|
nn.MsSsim = MsSsim
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue