Skip to content

Commit 08266af

Browse files
committed
minor change in TextClassificationTrain
1 parent f4d25c9 commit 08266af

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎src/TensorFlowNET.Core/Graphs/Graph.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,14 @@ private ITensorOrOperation _as_graph_element_locked(object obj, bool allow_tenso
160160
}
161161
else if (!name.Contains(":") & !allow_operation)
162162
{
163-
throw new NotImplementedException("_as_graph_element_locked");
163+
// Looks like an Operation name but can't be an Operation.
164+
if (_nodes_by_name.ContainsKey(name))
165+
// Yep, it's an Operation name
166+
throw new ValueError($"The name {name} refers to an Operation, not a {types_str}.");
167+
else
168+
throw new ValueError(
169+
$"The name {name} looks like an (invalid) Operation name, not a {types_str}" +
170+
" Tensor names must be of the form \"<op_name>:<output_index>\".");
164171
}
165172
}
166173

‎test/TensorFlowNET.Examples/TextProcess/TextClassificationTrain.cs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ protected virtual bool RunWithImportedGraph(Session sess, Graph graph)
7979
var num_batches_per_epoch = (len(train_x) - 1) / BATCH_SIZE + 1;
8080
double max_accuracy = 0;
8181

82-
Tensor is_training = graph.get_operation_by_name("is_training");
83-
Tensor model_x = graph.get_operation_by_name("x");
84-
Tensor model_y = graph.get_operation_by_name("y");
85-
Tensor loss = graph.get_operation_by_name("loss/value");
86-
Tensor optimizer = graph.get_operation_by_name("loss/optimizer");
87-
Tensor global_step = graph.get_operation_by_name("global_step");
88-
Tensor accuracy = graph.get_operation_by_name("accuracy/value");
82+
Tensor is_training = graph.get_tensor_by_name("is_training:0");
83+
Tensor model_x = graph.get_tensor_by_name("x:0");
84+
Tensor model_y = graph.get_tensor_by_name("y:0");
85+
Tensor loss = graph.get_tensor_by_name("loss/value:0");
86+
Tensor optimizer = graph.get_tensor_by_name("loss/optimizer:0");
87+
Tensor global_step = graph.get_tensor_by_name("global_step:0");
88+
Tensor accuracy = graph.get_tensor_by_name("accuracy/value:0");
8989
stopwatch = Stopwatch.StartNew();
9090
int i = 0;
9191
foreach (var (x_batch, y_batch, total) in train_batches)

0 commit comments

Comments
 (0)