提交 964ce8d8 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

better error messages

上级 86456da4
...@@ -165,11 +165,12 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None, ...@@ -165,11 +165,12 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
# I use the string value of the type to do type checking here since # I use the string value of the type to do type checking here since
# OrderedDict is not available in python2.4 # OrderedDict is not available in python2.4
if isinstance(updates, dict) and 'Ordered' not in str(type(updates)): if isinstance(updates, dict) and 'Ordered' not in str(type(updates)):
raise TypeError("Using a standard dictionary here results in " raise TypeError("Expected OrderedDict, got "+str(type(updates))+ "Using "
"a standard dictionary here results in "
"non-deterministic behavior. You should use an OrderedDict" "non-deterministic behavior. You should use an OrderedDict"
" if you are using python2.7 or use a list of (shared, update)" " if you are using python2.7 or use a list of (shared, update)"
" pairs. Do not just convert your dictionary to this type before" " pairs. Do not just convert your dictionary to this type before"
"the call as the conversion will still be non-deterministic.") " the call as the conversion will still be non-deterministic.")
if givens is None: if givens is None:
givens = [] givens = []
......
...@@ -203,7 +203,9 @@ def get_updates_and_outputs(ls): ...@@ -203,7 +203,9 @@ def get_updates_and_outputs(ls):
def is_updates(elem): def is_updates(elem):
if isinstance(elem, dict): if isinstance(elem, dict):
# Make sure the updates will be applied in a deterministic order # Make sure the updates will be applied in a deterministic order
assert 'Ordered' in str(type(elem)) if 'Ordered' not in str(type(elem)):
raise TypeError("Expected OrderedDict or OrderedUpdates, got "\
+str(type(elem)))
return True return True
# Dictionaries can be given as lists of tuples # Dictionaries can be given as lists of tuples
if (isinstance(elem, (list, tuple)) and if (isinstance(elem, (list, tuple)) and
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论