Skip to content

Commit 66eddd6

Browse files
committed
add debug info
1 parent f8b062f commit 66eddd6

15 files changed

Lines changed: 142 additions & 46 deletions

File tree

src/TensorFlowNET.Core/Framework/meta_graph.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static (Dictionary<string, VariableV1>, ITensorOrOperation[]) import_scop
134134
}
135135
break;
136136
default:
137-
Console.WriteLine("import_scoped_meta_graph_with_return_elements");
137+
Console.WriteLine($"import_scoped_meta_graph_with_return_elements {col.Key}");
138138
continue;
139139
}
140140
}

src/TensorFlowNET.Core/Framework/smart_module.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
******************************************************************************/
1616

1717
using System;
18+
using static Tensorflow.Binding;
1819

1920
namespace Tensorflow.Framework
2021
{

src/TensorFlowNET.Core/Graphs/Graph.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ all variables that are created during the construction of a graph. The caller
7575
/// then create a TensorFlow session to run parts of the graph across a set of local and remote devices.
7676
/// </summary>
7777
/// <remarks>https://www.tensorflow.org/guide/graphs <br></br>https://www.tensorflow.org/api_docs/python/tf/Graph</remarks>
78-
public partial class Graph : DisposableObject, IEnumerable<Operation>
78+
public partial class Graph : DisposableObject//, IEnumerable<Operation>
7979
{
8080
private Dictionary<int, ITensorOrOperation> _nodes_by_id;
8181
public Dictionary<string, ITensorOrOperation> _nodes_by_name;
@@ -257,17 +257,17 @@ public Operation create_op(string op_type, Tensor[] inputs, TF_DataType[] dtypes
257257
if (inputs == null)
258258
inputs = new Tensor[0];
259259

260-
foreach ((int idx, Tensor a) in enumerate(inputs))
261-
{
262-
263-
}
264-
265-
if (String.IsNullOrEmpty(name))
260+
if (string.IsNullOrEmpty(name))
266261
name = op_type;
267262
// If a names ends with a '/' it is a "name scope" and we use it as-is,
268263
// after removing the trailing '/'.
269264
name = name.EndsWith("/") ? ops.name_from_scope_name(name) : unique_name(name);
270265
var node_def = ops._NodeDef(op_type, name, device: "", attrs: attrs);
266+
267+
if (name.Contains("define_loss/bigger_box_loss/mul_13"))
268+
{
269+
270+
}
271271

272272
var input_ops = inputs.Select(x => x.op).ToArray();
273273
var control_inputs = _control_dependencies_for_inputs(input_ops);
@@ -526,14 +526,14 @@ public override string ToString()
526526
return debugString;*/
527527
}
528528

529-
private IEnumerable<Operation> GetEnumerable()
529+
/*private IEnumerable<Operation> GetEnumerable()
530530
=> c_api_util.tf_operations(this);
531531
532532
IEnumerator<Operation> IEnumerable<Operation>.GetEnumerator()
533533
=> GetEnumerable().GetEnumerator();
534534
535535
IEnumerator IEnumerable.GetEnumerator()
536-
=> throw new NotImplementedException();
536+
=> throw new NotImplementedException();*/
537537

538538
public static implicit operator IntPtr(Graph graph)
539539
{

src/TensorFlowNET.Core/Operations/NnOps/gen_nn_ops.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ You may obtain a copy of the License at
1414
limitations under the License.
1515
******************************************************************************/
1616

17+
using static Tensorflow.Binding;
18+
1719
namespace Tensorflow.Operations
1820
{
1921
public class gen_nn_ops

src/TensorFlowNET.Core/Operations/Operation.Control.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ public void _add_control_inputs(Operation[] ops)
5454

5555
public void _set_control_flow_context(ControlFlowContext ctx)
5656
{
57-
if(name == "define_loss/conv_sobj_branch/batch_normalization/cond/FusedBatchNorm_1")
58-
{
59-
60-
}
6157
_control_flow_context = ctx;
6258
}
6359

src/TensorFlowNET.Core/Operations/Operation.Input.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ You may obtain a copy of the License at
1414
limitations under the License.
1515
******************************************************************************/
1616

17+
using Newtonsoft.Json;
1718
using System;
1819
using System.Linq;
1920
using System.Runtime.InteropServices;
@@ -37,7 +38,9 @@ public int InputListLength(string name)
3738
}
3839
return num;
3940
}
40-
41+
#if SERIALIZABLE
42+
[JsonIgnore]
43+
#endif
4144
public int NumInputs => c_api.TF_OperationNumInputs(_handle);
4245
private TF_DataType[] _input_types => _inputs._inputs.Select(x => x.dtype).ToArray();
4346

src/TensorFlowNET.Core/Operations/Operation.Output.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ You may obtain a copy of the License at
1414
limitations under the License.
1515
******************************************************************************/
1616

17+
using Newtonsoft.Json;
1718
using System;
1819
using System.Linq;
1920
using System.Runtime.InteropServices;
@@ -23,6 +24,9 @@ namespace Tensorflow
2324
{
2425
public partial class Operation
2526
{
27+
#if SERIALIZABLE
28+
[JsonIgnore]
29+
#endif
2630
public int NumOutputs => c_api.TF_OperationNumOutputs(_handle);
2731
public TF_DataType OutputType(int index) => c_api.TF_OperationOutputType(_tf_output(index));
2832

@@ -40,7 +44,9 @@ public int OutputListLength(string name)
4044

4145
private Tensor[] _outputs;
4246
public Tensor[] outputs => _outputs;
43-
47+
#if SERIALIZABLE
48+
[JsonIgnore]
49+
#endif
4450
public Tensor output => _outputs.FirstOrDefault();
4551

4652
public int NumControlOutputs => c_api.TF_OperationNumControlOutputs(_handle);

src/TensorFlowNET.Core/Operations/Operation.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ limitations under the License.
1515
******************************************************************************/
1616

1717
using Google.Protobuf.Collections;
18+
#if SERIALIZABLE
19+
using Newtonsoft.Json;
20+
#endif
1821
using System;
1922
using System.Collections.Generic;
2023
using System.IO;
@@ -43,20 +46,37 @@ namespace Tensorflow
4346
/// </summary>
4447
public partial class Operation : ITensorOrOperation
4548
{
46-
private readonly IntPtr _handle; // _c_op in python
47-
private readonly Graph _graph;
48-
private NodeDef _node_def;
49+
private readonly IntPtr _handle; // _c_op in python
4950

50-
public string type => OpType;
51-
public Graph graph => _graph;
52-
public int _id => _id_value;
53-
public int _id_value;
51+
private readonly Graph _graph;
52+
private NodeDef _node_def;
53+
#if SERIALIZABLE
54+
[JsonIgnore]
55+
#endif
56+
public string type => OpType;
57+
#if SERIALIZABLE
58+
[JsonIgnore]
59+
#endif
60+
public Graph graph => _graph;
61+
#if SERIALIZABLE
62+
[JsonIgnore]
63+
#endif
64+
public int _id => _id_value;
65+
#if SERIALIZABLE
66+
[JsonIgnore]
67+
#endif
68+
public int _id_value;
69+
#if SERIALIZABLE
70+
[JsonIgnore]
71+
#endif
5472
public Operation op => this;
5573
public TF_DataType dtype => TF_DataType.DtInvalid;
5674
public string name => _handle == IntPtr.Zero ? null : c_api.StringPiece(c_api.TF_OperationName(_handle));
5775
public string OpType => _handle == IntPtr.Zero ? null : c_api.StringPiece(c_api.TF_OperationOpType(_handle));
58-
public string Device => _handle == IntPtr.Zero ? null : c_api.StringPiece(c_api.TF_OperationDevice(_handle));
59-
76+
public string Device => _handle == IntPtr.Zero ? null : c_api.StringPiece(c_api.TF_OperationDevice(_handle));
77+
#if SERIALIZABLE
78+
[JsonIgnore]
79+
#endif
6080
public NodeDef node_def
6181
{
6282
get

src/TensorFlowNET.Core/TensorFlowNET.Core.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AssemblyName>TensorFlow.NET</AssemblyName>
66
<RootNamespace>Tensorflow</RootNamespace>
77
<TargetTensorFlow>1.14.0</TargetTensorFlow>
8-
<Version>0.11.7</Version>
8+
<Version>0.11.8</Version>
99
<Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors>
1010
<Company>SciSharp STACK</Company>
1111
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -17,7 +17,7 @@
1717
<PackageTags>TensorFlow, NumSharp, SciSharp, MachineLearning, TensorFlow.NET, C#</PackageTags>
1818
<Description>Google's TensorFlow full binding in .NET Standard.
1919
Docs: https://tensorflownet.readthedocs.io</Description>
20-
<AssemblyVersion>0.11.7.0</AssemblyVersion>
20+
<AssemblyVersion>0.11.8.0</AssemblyVersion>
2121
<PackageReleaseNotes>Changes since v0.10.0:
2222
1. Upgrade NumSharp to v0.20.3.
2323
2. Add DisposableObject class to manage object lifetime.
@@ -34,7 +34,7 @@ Docs: https://tensorflownet.readthedocs.io</Description>
3434
13. Return VariableV1 instead of RefVariable.
3535
14. Add Tensor overload to GradientDescentOptimizer.</PackageReleaseNotes>
3636
<LangVersion>7.3</LangVersion>
37-
<FileVersion>0.11.7.0</FileVersion>
37+
<FileVersion>0.11.8.0</FileVersion>
3838
<PackageLicenseFile>LICENSE</PackageLicenseFile>
3939
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
4040
<SignAssembly>true</SignAssembly>
@@ -43,7 +43,7 @@ Docs: https://tensorflownet.readthedocs.io</Description>
4343

4444
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
4545
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
46-
<DefineConstants>TRACE;DEBUG</DefineConstants>
46+
<DefineConstants>TRACE;DEBUG;SERIALIZABLE</DefineConstants>
4747
</PropertyGroup>
4848

4949
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@@ -66,6 +66,7 @@ Docs: https://tensorflownet.readthedocs.io</Description>
6666

6767
<ItemGroup>
6868
<PackageReference Include="Google.Protobuf" Version="3.5.1" />
69+
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
6970
<PackageReference Include="NumSharp" Version="0.20.4" />
7071
</ItemGroup>
7172

src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ limitations under the License.
2525
using NumSharp.Backends;
2626
using NumSharp.Backends.Unmanaged;
2727
using static Tensorflow.c_api;
28+
using Newtonsoft.Json;
2829

2930
namespace Tensorflow
3031
{
@@ -44,11 +45,17 @@ public partial class Tensor
4445
/// <summary>
4546
/// True if this Tensor holds data allocated by C#.
4647
/// </summary>
48+
#if SERIALIZABLE
49+
[JsonIgnore]
50+
#endif
4751
public bool IsMemoryOwner => AllocationType >= AllocationType.Marshal;
4852

4953
/// <summary>
5054
/// The allocation method used to create this Tensor.
5155
/// </summary>
56+
#if SERIALIZABLE
57+
[JsonIgnore]
58+
#endif
5259
public AllocationType AllocationType { get; protected set; }
5360

5461
/// <summary>

0 commit comments

Comments
 (0)