paddle数据Tensor
1.根据输入数据构建loader
src = fluid.data(name="src", shape=[None, None], dtype="int64") src_sequence_length = fluid.data(name="src_sequence_length",shape=[None],dtype="int64") inputs = [src, src_sequence_length] loader = fluid.io.DataLoader.from_generator(feed_list=inputs,capacity=10, iterable=True,use_double_buffer=True)
loader.set_batch_generator(reader,places=places)
之后loader会将输入的Tensor自动转化为输入需要的lodTensor
2.program
train_prog = fluid.Program() startup_prog = fluid.Program() with fluid.program_guard(train_prog, startup_prog): with fluid.unique_name.guard(): pass
默认情况下网络是在default_main_program中,如果要自定义program必须使用with结构