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();