Commit 8d7f3991 authored by Steven Kearnes's avatar Steven Kearnes
Browse files

Fix regressor cost

The regression loss function is wrong in tfvs. `tf.nn.l2_loss` returns a scalar (the sum of the per-example weights), which obviously will frequently get the weighted losses wrong. This PR calculates per-example losses, which are then weighted appropriately. (Sorry, this should have been fixed when tfvs was released.)
parent 3c8e5b6c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -655,7 +655,7 @@ class TensorflowRegressor(TensorflowGraph):
      A tensor with shape batch_size containing the weighted cost for each
      example.
    """
    return tf.mul(tf.nn.l2_loss(output - labels), weights)
    return tf.mul(0.5 * tf.square(output - labels), weights)

  def example_counts(self, y_true):
    """Get counts of examples in each class.