Created by: zhouwei25
修复了save_vars/save_persistable/save_params
在Windows下出现中文乱码的bug。
Python3默认使用unicode编码,而Windows对C++代码使用gbk编码,因此当传入字符串到pybind时,已经乱码了,需要在python端先进行gbk编码。
测试代码:
import paddle.fluid as fluid
dir_path = "./测试路径"
file_name = "persistables"
image = fluid.layers.data(name='img', shape=[1, 28, 28], dtype='float32')
label = fluid.layers.data(name='label', shape=[1], dtype='int64')
feeder = fluid.DataFeeder(feed_list=[image, label], place=fluid.CPUPlace())
predict = fluid.layers.fc(input=image, size=10, act='softmax')
loss = fluid.layers.cross_entropy(input=predict, label=label)
avg_loss = fluid.layers.mean(loss)
exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_startup_program())
fluid.io.save_persistables(executor=exe, dirname=dir_path)