Browse Source

fixed Minimum - CategoricalCrossentropy #901

tags/TimeSeries
Oceania2018 3 years ago
parent
commit
22d362ec13
2 changed files with 3 additions and 6 deletions
  1. +1
    -4
      src/TensorFlowNET.Core/Graphs/Graph.Control.cs
  2. +2
    -2
      src/TensorFlowNET.Keras/BackendImpl.cs

+ 1
- 4
src/TensorFlowNET.Core/Graphs/Graph.Control.cs View File

@@ -81,10 +81,7 @@ namespace Tensorflow
/// </summary>
public _ControlDependenciesController control_dependencies(object[] control_inputs)
{
if (tf.Context.executing_eagerly())
return new _ControlDependenciesController(this, null);

if (control_inputs == null)
if (control_inputs == null || tf.Context.executing_eagerly())
return new _ControlDependenciesController(this, null);

var control_ops = new List<ITensorOrOperation>();


+ 2
- 2
src/TensorFlowNET.Keras/BackendImpl.cs View File

@@ -264,7 +264,7 @@ namespace Tensorflow.Keras
if (output.op != null && output.op.type == "Softmax")
{
if (output.op.inputs.Length != 1) throw new ApplicationException();
var o = output = output.op.inputs[0];
var o = output.op.inputs[0];
return tf.nn.softmax_cross_entropy_with_logits_v2(labels: target, logits: o, axis: axis);
}

@@ -272,7 +272,7 @@ namespace Tensorflow.Keras
output = output / math_ops.reduce_sum(output, new Axis(axis), true);
// Compute cross entropy from probabilities.
var epsilon_ = constant_op.constant(epsilon(), output.dtype.as_base_dtype());
output = clip_ops.clip_by_value(output, epsilon_, 1.0 - epsilon_);
output = clip_ops.clip_by_value(output, epsilon_, 1.0f - epsilon_);
return -math_ops.reduce_sum(target * math_ops.log(output), new Axis(axis));
}



Loading…
Cancel
Save