python tree.map_structure
可见,map_structure 会对所有的 dict 和 list (不包括 numpy.array) 展开,并将相同位置的元素传入。显然传入的元素其类型不可能是 dict 和 list。
def foo(x): assert not type(x) is dict ... ...
python tree.map_structure
可见,map_structure 会对所有的 dict 和 list (不包括 numpy.array) 展开,并将相同位置的元素传入。显然传入的元素其类型不可能是 dict 和 list。
def foo(x): assert not type(x) is dict ... ...