From 22d362ec13dc248e147afc6d6a3d75dddaf893c6 Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Sun, 2 Jan 2022 13:20:05 -0600 Subject: [PATCH] fixed Minimum - CategoricalCrossentropy #901 --- src/TensorFlowNET.Core/Graphs/Graph.Control.cs | 5 +---- src/TensorFlowNET.Keras/BackendImpl.cs | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/TensorFlowNET.Core/Graphs/Graph.Control.cs b/src/TensorFlowNET.Core/Graphs/Graph.Control.cs index f71ab881..15cf90f1 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.Control.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.Control.cs @@ -81,10 +81,7 @@ namespace Tensorflow /// 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(); diff --git a/src/TensorFlowNET.Keras/BackendImpl.cs b/src/TensorFlowNET.Keras/BackendImpl.cs index 7588647d..a62e8196 100644 --- a/src/TensorFlowNET.Keras/BackendImpl.cs +++ b/src/TensorFlowNET.Keras/BackendImpl.cs @@ -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)); }