diff --git a/src/TensorFlowNET.Core/Operations/Operation.Implicit.cs b/src/TensorFlowNET.Core/Operations/Operation.Implicit.cs index 9cadac0c..289c69ad 100644 --- a/src/TensorFlowNET.Core/Operations/Operation.Implicit.cs +++ b/src/TensorFlowNET.Core/Operations/Operation.Implicit.cs @@ -27,8 +27,12 @@ namespace Tensorflow public static implicit operator Operation(IntPtr handle) => new Operation(handle); - public static implicit operator IntPtr(Operation op) => op._handle; - public static implicit operator Tensor(Operation op) => op.output; + public static implicit operator IntPtr(Operation op) + => op._handle; + public static implicit operator Tensor(Operation op) + => op.output; + public static implicit operator RefVariable(Operation op) + => new RefVariable(op); public override string ToString() { diff --git a/src/TensorFlowNET.Core/Operations/Operation.cs b/src/TensorFlowNET.Core/Operations/Operation.cs index 029f8d69..65097d5b 100644 --- a/src/TensorFlowNET.Core/Operations/Operation.cs +++ b/src/TensorFlowNET.Core/Operations/Operation.cs @@ -106,7 +106,7 @@ namespace Tensorflow _outputs = new Tensor[NumOutputs]; for (int i = 0; i < NumOutputs; i++) _outputs[i] = new Tensor(this, i, OutputType(i)); - + // Dict mapping op name to file and line information for op colocation // context managers. _control_flow_context = _graph._get_control_flow_context(); diff --git a/src/TensorFlowNET.Core/TensorFlow.Binding.csproj b/src/TensorFlowNET.Core/TensorFlow.Binding.csproj index 369c6c81..0e1c7622 100644 --- a/src/TensorFlowNET.Core/TensorFlow.Binding.csproj +++ b/src/TensorFlowNET.Core/TensorFlow.Binding.csproj @@ -5,7 +5,7 @@ TensorFlow.NET Tensorflow 1.14.1 - 0.14.2.0 + 0.15.0 Haiping Chen, Meinrad Recheis, Eli Belash SciSharp STACK true @@ -18,13 +18,15 @@ Google's TensorFlow full binding in .NET Standard. Building, training and infering deep learning models. https://tensorflownet.readthedocs.io - 0.14.2.0 + 0.15.0.0 Changes since v0.14.0: 1: Add TransformGraphWithStringInputs. 2: tf.trainer.load_graph, tf.trainer.freeze_graph -3: Import Protobuf.Text +3: Import Protobuf.Text +4: Support YOLOv3 object detection +5: Add implicitation for Operation to RefVariable 7.3 - 0.14.2.0 + 0.15.0.0 LICENSE true true @@ -33,7 +35,7 @@ https://tensorflownet.readthedocs.io true - TRACE;DEBUG;SERIALIZABLE + TRACE;DEBUG;SERIALIZABLE_ @@ -62,7 +64,6 @@ https://tensorflownet.readthedocs.io - diff --git a/src/TensorFlowNET.Core/Variables/RefVariable.cs b/src/TensorFlowNET.Core/Variables/RefVariable.cs index c79c5b7f..cff14ec1 100644 --- a/src/TensorFlowNET.Core/Variables/RefVariable.cs +++ b/src/TensorFlowNET.Core/Variables/RefVariable.cs @@ -61,7 +61,11 @@ namespace Tensorflow { _in_graph_mode = true; - if (variable_def != null) + if(initial_value is Operation op) + { + _init_from_op(op); + } + else if (variable_def != null) { if (initial_value != null) throw new ValueError("variable_def and initial_value are mutually exclusive."); @@ -73,6 +77,13 @@ namespace Tensorflow } } + private void _init_from_op(Operation op) + { + var g = ops.get_default_graph(); + _initializer_op = op; + _variable = op.output; + } + private void _init_from_proto(VariableDef variable_def, string import_scope = "") { var g = ops.get_default_graph();