提交 35f1dfde 编写于 作者: Q qiaolongfei

chage trainer.save_parameter to trainer.save_parameter_to_tar

上级 68c1efdd
...@@ -29,7 +29,7 @@ def main(): ...@@ -29,7 +29,7 @@ def main():
else: else:
paddle.init( paddle.init(
use_gpu=False, use_gpu=False,
trainer_count=1, trainer_count=2,
port=7164, port=7164,
ports_num=1, ports_num=1,
ports_num_for_sparse=1, ports_num_for_sparse=1,
...@@ -69,7 +69,7 @@ def main(): ...@@ -69,7 +69,7 @@ def main():
def event_handler(event): def event_handler(event):
if isinstance(event, paddle.event.EndIteration): if isinstance(event, paddle.event.EndIteration):
if event.batch_id % 100 == 0: if event.batch_id % 100 == 0:
trainer.save_parameter("output", "batch-" + str(event.batch_id)) trainer.save_parameter_to_tar("output", "batch-" + str(event.batch_id))
result = trainer.test( result = trainer.test(
paddle.batch( paddle.batch(
paddle.dataset.imikolov.test(word_dict, N), 32)) paddle.dataset.imikolov.test(word_dict, N), 32))
......
...@@ -98,7 +98,7 @@ class SGD(object): ...@@ -98,7 +98,7 @@ class SGD(object):
self.__gradient_machine__.prefetch(in_args) self.__gradient_machine__.prefetch(in_args)
self.__parameter_updater__.getParametersRemote() self.__parameter_updater__.getParametersRemote()
def save_parameter(self, dir_name, file_name): def save_parameter_to_tar(self, dir_name, file_name):
if not os.path.exists(dir_name): if not os.path.exists(dir_name):
os.makedirs(dir_name) os.makedirs(dir_name)
param_file_name = dir_name + "/" + file_name + '.tar.gz' param_file_name = dir_name + "/" + file_name + '.tar.gz'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册