2 different functions named __as_list and __as_iterator
@@ -4,10 +4,10 @@ They might be Keanu tensors or Numpy arrays
"""
def tensors_equal(t1, t2):
if not shapes_equal(__get_shape(t1), __get_shape(t2)):
- print("Shapes don't match", __get_shape(t1), __get_shape(t2))
+ print("Shapes don't match: %s != %s" % (__as_list(__get_shape(t1)), __as_list(__get_shape(t2))))
return False
- it1 = __as_list(t1)
- it2 = __as_list(t2)
+ it1 = __as_iterator(t1)
+ it2 = __as_iterator(t2)
for idx, value in enumerate(zip(it1, it2)):
if value[0] != value[1]:
print("Mismatch at position %d: %s != %s" % (idx, value[0], value[1]))
@@ -34,10 +34,13 @@ def __get_length(t):
try:
return len(t)
except:
- return len(__as_list(t))
+ return len(__as_iterator(t))
-def __as_list(t):
+def __as_iterator(t):
try:
return (i for i in t.asFlatArray())
except:
return (i for i in t)
+
+def __as_list(t):
+ return list(__as_iterator(t))
\ No newline at end of file
