From 4205c508aede8ce4ad65c76aafec7dc9ee3501c4 Mon Sep 17 00:00:00 2001 From: moloneymb Date: Thu, 4 Apr 2019 16:23:25 -0500 Subject: [PATCH] Removing the requirment for optional attributes to have a value --- .../Operations/OpDefLibrary.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs b/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs index bfecf60f..9e8bf374 100644 --- a/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs +++ b/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs @@ -160,15 +160,18 @@ namespace Tensorflow // Convert attr values to AttrValue protos. var attr_protos = new Dictionary(); - foreach (var attr_def in op_def.Attr) + foreach (AttrDef attr_def in op_def.Attr) { var key = attr_def.Name; - var value = attrs[key]; - - if (!attrs.ContainsKey(key)) - Console.WriteLine($"_apply_op_helper: key '{key}' is not found in '{op_def.Name}' operation's attr_def."); - - attr_protos[key] = SetAttrValue(op_def, attr_def, value); + if (attrs.ContainsKey(key)) + { + attr_protos[key] = SetAttrValue(op_def, attr_def, attrs[key]); + } else { + if (attr_def.DefaultValue == null) + { + throw new TypeError("Missing required positional argument " + key); + } + } } attrs.Clear();