提交 d58bf354 编写于 作者: S silingtong123

test=develop, modfiyt he example code

上级 ea6c8797
...@@ -42,7 +42,6 @@ NCE ...@@ -42,7 +42,6 @@ NCE
words.append(fluid.dygraph.base.to_variable(inp_word[i])) words.append(fluid.dygraph.base.to_variable(inp_word[i]))
emb = fluid.Embedding( emb = fluid.Embedding(
'embedding',
size=[dict_size, 32], size=[dict_size, 32],
param_attr='emb.w', param_attr='emb.w',
is_sparse=False) is_sparse=False)
...@@ -57,17 +56,17 @@ NCE ...@@ -57,17 +56,17 @@ NCE
embs3 = fluid.layers.concat(input=embs3, axis=1) embs3 = fluid.layers.concat(input=embs3, axis=1)
nce = fluid.NCE( nce = fluid.NCE(
num_total_classes=dict_size, num_total_classes=dict_size,
dim=embs3.shape[1], dim=embs3.shape[1],
num_neg_samples=2, num_neg_samples=2,
sampler="custom_dist", sampler="custom_dist",
custom_dist=nid_freq_arr.tolist(), custom_dist=nid_freq_arr.tolist(),
seed=1, seed=1,
param_attr='nce.w', param_attr='nce.w',
bias_attr='nce.b') bias_attr='nce.b')
wl = fluid.layers.unsqueeze(words[label_word], axes=[0]) wl = fluid.layers.unsqueeze(words[label_word], axes=[0])
nce_loss3 = nce(embs3, words[label_word]) nce_loss3 = nce(embs3, wl)
属性 属性
:::::::::::: ::::::::::::
......
...@@ -52,10 +52,8 @@ PolynomialDecay ...@@ -52,10 +52,8 @@ PolynomialDecay
total_step = 5000 total_step = 5000
end_lr = 0 end_lr = 0
with fluid.dygraph.guard(): with fluid.dygraph.guard():
emb = fluid.dygraph.Embedding( [10, 10])
optimizer = fluid.optimizer.SGD( optimizer = fluid.optimizer.SGD(
learning_rate = fluid.dygraph.PolynomialDecay( learning_rate = fluid.dygraph.PolynomialDecay(
start_lr, total_step, end_lr, power=1.0) ) start_lr, total_step, end_lr, power=1.0),
parameter_list = emb.parameters())
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册