Browse Source

Fix RunInAutoMode.

tags/yolov3
Oceania2018 4 years ago
parent
commit
a7f95991a6
3 changed files with 15 additions and 9 deletions
  1. +13
    -7
      src/TensorFlowNET.Core/Contexts/Context.AutoMode.cs
  2. +1
    -1
      src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs
  3. +1
    -1
      src/TensorFlowNET.Core/Variables/ResourceVariable.Implicit.cs

+ 13
- 7
src/TensorFlowNET.Core/Contexts/Context.AutoMode.cs View File

@@ -32,19 +32,25 @@ namespace Tensorflow.Contexts
{ {
if (tf.Context.has_graph_arg(args)) if (tf.Context.has_graph_arg(args))
{ {
return graphAction();
if (executing_eagerly())
{
graph_mode();
var result = graphAction();
restore_mode();
return result;
}
else
{
return graphAction();
}
} }
else else
{ {
try
if (tf.Context.executing_eagerly())
{ {
return eagerAction(); return eagerAction();
} }
catch (InvalidArgumentError ex)
{
throw ex;
}
catch (Exception ex)
else
{ {
return graphAction(); return graphAction();
} }


+ 1
- 1
src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs View File

@@ -162,7 +162,7 @@ namespace Tensorflow
/// read the value only after some condition is true. /// read the value only after some condition is true.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Tensor read_value()
protected Tensor read_value()
=> tf_with(ops.name_scope("Read"), delegate => tf_with(ops.name_scope("Read"), delegate
{ {
var value = _read_variable_op(); var value = _read_variable_op();


+ 1
- 1
src/TensorFlowNET.Core/Variables/ResourceVariable.Implicit.cs View File

@@ -36,7 +36,7 @@ namespace Tensorflow
if (as_ref) if (as_ref)
return handle; return handle;
else else
return AsTensor();
return GraphElement ?? read_value();
} }
} }
} }

Loading…
Cancel
Save