def set_shared_params(a, b):
"""Set shared params to a link.
Args:
a (chainer.Link): link whose params are to be replaced
b (dict): dict that consists of (param_name, multiprocessing.Array)
"""
assert isinstance(a, chainer.Link)
for param_name, param in a.namedparams():
if param_name in b:
shared_param = b[param_name]
param.data = np.frombuffer(
shared_param, dtype=param.data.dtype).reshape(param.data.shape)
评论列表
文章目录