Skip to content

Commit b3f72cd

Browse files
dataangelOceania2018
authored andcommitted
Update losses_utils.cs
1 parent 71f569b commit b3f72cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/TensorFlowNET.Keras/Utils/losses_utils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*****************************************************************************
1+
/*****************************************************************************
22
Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,7 +25,7 @@ public class losses_utils
2525
public static Tensor compute_weighted_loss(Tensor losses, Tensor sample_weight = null, string reduction = null, string name = null)
2626
{
2727
if (sample_weight == null)
28-
sample_weight = tf.constant(1.0f);
28+
sample_weight = losses.dtype == TF_DataType.TF_DOUBLE ? tf.constant(1.0) : tf.constant(1.0f);
2929
var weighted_losses = scale_losses_by_sample_weight(losses, sample_weight);
3030
// Apply reduction function to the individual weighted losses.
3131
var loss = reduce_weighted_loss(weighted_losses, reduction);

0 commit comments

Comments
 (0)