How to share embeding in two Program?
Created by: qingqing01
Q: How to share embedding in two Program? [From 用户群]
A: You can set the same name of param_attr
in fluid.layers.embedding
, like:
import paddle.fluid as fluid
from paddle.fluid.param_attr import ParamAttr
a = fluid.Program()
with fluid.proram_guard(a):
x = fluid.layers.data(name='x', shape=[1], dtype='float32')
emb = fluid.layers.embedding(input=x, is_sparse=True, size=[1, 10], param_attr=ParamAttr(name="embedding_w"))
b = fluid.Program()
with fluid.proram_guard(b):
y = fluid.layers.data(name='y', shape=[1], dtype='float32')
emb = fluid.layers.embedding(input=y, is_sparse=True, size=[1, 10], param_attr=ParamAttr(name="embedding_w"))