You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def __setattr__(self, name, value):
if isinstance(value, (list, tuple)):
value = [self.__class__(x)
if isinstance(x, dict) else x for x in value]
elif isinstance(value, dict) and not isinstance(value, self.__class__):
value = self.__class__(value)
super(EasyDict, self).__setattr__(name, value)
super(EasyDict, self).__setitem__(name, value)
I want to know why make dict to easydict.
I use the type dict of value , then this value can not use multiple gpu.
The text was updated successfully, but these errors were encountered:
def scatter(inputs, target_gpus, dim=0):
def scatter_map(obj):
if isinstance(obj, torch.Tensor):
return Scatter.apply(target_gpus, None, dim, obj)
if isinstance(obj, tuple) and len(obj) > 0:
return list(zip(*map(scatter_map, obj)))
if isinstance(obj, list) and len(obj) > 0:
return list(map(list, zip(*map(scatter_map, obj))))
if isinstance(obj, dict) and len(obj) > 0:
return list(map(type(obj), zip(*map(scatter_map, obj.items()))))
return [obj for targets in target_gpus]
try:
res = scatter_map(inputs)
finally:
scatter_map = None
return res
from easydict import EasyDict as edict
batch = edict()
a = dict({"st":[12, 29, 5, 8]})
batch["ts_label"] = a
target_gpus = [0,1]
print(type(batch["ts_label"])) # easydict not dict
output = scatter(batch["ts_label"],target_gpus)
print(output)
File "/home/ll/anaconda3/envs/py27_torch/lib/python2.7/site-packages/easydict/__init__.py", line 117, in __init__
for k, v in d.items():
AttributeError: 'tuple' object has no attribute 'items'
the function scatter is from torch.nn.data_parallel.py
I want to know why make dict to easydict.
I use the type dict of value , then this value can not use multiple gpu.
The text was updated successfully, but these errors were encountered: