提交 b42065bc 编写于 作者: W wuzewu
......@@ -124,11 +124,6 @@ def train_net(train_reader,
sgd_optimizer = fluid.optimizer.Adagrad(learning_rate=lr)
sgd_optimizer.minimize(cost)
# write default main program
with open("./bow_net.backward.program_desc.prototxt", "w") as fo:
program_desc = str(fluid.default_main_program())
fo.write(program_desc)
# set place, executor, datafeeder
place = fluid.CUDAPlace(0) if use_gpu else fluid.CPUPlace()
exe = fluid.Executor(place)
......@@ -221,10 +216,10 @@ def finetune_net(train_reader,
fluid.layers.cross_entropy(input=pred, label=label))
acc = fluid.layers.accuracy(input=pred, label=label)
with open("./prototxt/bow_net.forward.program_desc.prototxt",
"w") as fo:
program_desc = str(fluid.default_main_program())
fo.write(program_desc)
# with open("./prototxt/bow_net.forward.program_desc.prototxt",
# "w") as fo:
# program_desc = str(fluid.default_main_program())
# fo.write(program_desc)
# set optimizer
sgd_optimizer = fluid.optimizer.Adagrad(learning_rate=lr)
sgd_optimizer.minimize(cost)
......
......@@ -194,7 +194,7 @@ class Module(object):
return lod_tensor
def _word_id_mapping(self, inputs):
word_dict = self.config.get_dict()
word_dict = self.config.get_assets_vocab()
return list(map(lambda x: word_dict[x], inputs))
......@@ -214,7 +214,7 @@ class ModuleConfig(object):
self.dict = defaultdict(int)
self.dict.setdefault(0)
def get_dict(self):
def get_assets_vocab(self):
""" Return dictionary in Module"""
return self.dict
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册