@@ -41,10 +41,13 @@ namespace TensorFlowNET.Core | |||||
name = op_type; | name = op_type; | ||||
} | } | ||||
name = unique_name(name); | |||||
name = name.EndsWith("/") ? ops._name_from_scope_name(name) : unique_name(name); | |||||
var node_def = ops._NodeDef(op_type, name, device: "", attrs: attrs); | var node_def = ops._NodeDef(op_type, name, device: "", attrs: attrs); | ||||
var op = new Operation(node_def, this, inputs, dtypes); | |||||
var op = new Operation(node_def, this, | |||||
inputs: inputs, | |||||
output_types: dtypes, | |||||
op_def: op_def); | |||||
return op; | return op; | ||||
} | } | ||||
@@ -86,8 +86,8 @@ namespace TensorFlowNET.Core | |||||
var op = g.create_op(op_type_name, null, output_types.ToArray(), | var op = g.create_op(op_type_name, null, output_types.ToArray(), | ||||
name: "Placeholder_1/", | name: "Placeholder_1/", | ||||
input_types: new DataType[] { }, | input_types: new DataType[] { }, | ||||
attrs: null, | |||||
op_def: null); | |||||
attrs: attr_protos, | |||||
op_def: op_def); | |||||
return op; | return op; | ||||
} | } | ||||
@@ -15,8 +15,9 @@ namespace TensorFlowNET.Core | |||||
public string name; | public string name; | ||||
private Tensor[] _outputs; | private Tensor[] _outputs; | ||||
public Tensor[] outputs => _outputs; | public Tensor[] outputs => _outputs; | ||||
public Tensor[] inputs; | |||||
public Operation(NodeDef node_def, Graph g, object inputs = null, TF_DataType[] output_types = null, object control_inputs = null, TF_DataType[] input_types = null, string original_op = "", string op_def = "") | |||||
public Operation(NodeDef node_def, Graph g, object inputs = null, TF_DataType[] output_types = null, object control_inputs = null, TF_DataType[] input_types = null, string original_op = "", OpDef op_def = null) | |||||
{ | { | ||||
_graph = g; | _graph = g; | ||||
@@ -32,5 +33,24 @@ namespace TensorFlowNET.Core | |||||
_graph._add_op(this); | _graph._add_op(this); | ||||
} | } | ||||
public object get_attr(string name) | |||||
{ | |||||
object ret = null; | |||||
var fields = new string[] { "s", "i", "f", "b", "type", "shape", "tensor", "func" }; | |||||
switch (name) | |||||
{ | |||||
case "dtype": | |||||
ret = _outputs[0]; | |||||
break; | |||||
case "shape": | |||||
ret = new TensorShapeProto(); | |||||
break; | |||||
} | |||||
return ret; | |||||
} | |||||
} | } | ||||
} | } |
@@ -12,7 +12,13 @@ namespace TensorFlowNET.Core | |||||
public static Tensor placeholder(DataType dtype, TensorShape shape = null) | public static Tensor placeholder(DataType dtype, TensorShape shape = null) | ||||
{ | { | ||||
var op = _op_def_lib._apply_op_helper("Placeholder", dtype: dtype, shape: shape); | |||||
var _op = _op_def_lib._apply_op_helper("Placeholder", dtype: dtype, shape: shape); | |||||
var _result = _op.outputs; | |||||
var _inputs_flat = _op.inputs; | |||||
var _attrs = new Dictionary<string, object>(); | |||||
_attrs["dtype"] = _op.get_attr("dtype"); | |||||
_attrs["shape"] = _op.get_attr("shape"); | |||||
return null; | return null; | ||||
} | } | ||||
@@ -49,6 +49,18 @@ namespace TensorFlowNET.Core | |||||
return node_def; | return node_def; | ||||
} | } | ||||
public static string _name_from_scope_name(string name) | |||||
{ | |||||
if (name.EndsWith("/")) | |||||
{ | |||||
return name.Substring(0, name.Length - 1); | |||||
} | |||||
else | |||||
{ | |||||
return name; | |||||
} | |||||
} | |||||
public static int uid() | public static int uid() | ||||
{ | { | ||||
return 1; | return 1; | ||||