在fluid中对两个loss分别计算梯度,回传更新参数
Created by: Emma-Ding
` def train(pserver_endpoints, training_role, current_endpoint, trainer_num, trainer_id, pserver_id, batch_size, use_parallel_executor=False, use_cuda=False, is_sparse=True, is_local=True):
#data_list, predict, auc_var, cur_auc, auc_var_cos, cur_auc_cos, avg_cost, label, py_reader = net.model()
data_list, predict_cos, auc_var, cur_auc, avg_cost,avg_shantou, label, py_reader = net.model()
sgd_optimizer = fluid.optimizer.Adam(learning_rate=0.0002)
optimize_ops, params_grads = sgd_optimizer.minimize(avg_cost)
optimize_ops_a, params_grads_a = sgd_optimizer.minimize(avg_cost_shantou)
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
exe = fluid.Executor(place)
data_name_list = [data.name for data in data_list]
feeder = fluid.DataFeeder(feed_list=data_list, place=place)
ctr = ctrdata.CTRData()
with open('main.proto', 'w') as f:
f.write(str(fluid.default_main_program()))
def train_loop(main_program, trainer_id=None):
"""train loop
"""
# prepare data`
如图配置,并不行,求问要怎么配置