@@ -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(); | ||||
} | } | ||||
@@ -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(); | ||||
@@ -36,7 +36,7 @@ namespace Tensorflow | |||||
if (as_ref) | if (as_ref) | ||||
return handle; | return handle; | ||||
else | else | ||||
return AsTensor(); | |||||
return GraphElement ?? read_value(); | |||||
} | } | ||||
} | } | ||||
} | } |