def train_model1(sess, train_op, n_epoch, opt, model1, X_dataset, Y_dataset, Z_dataset, qvars, pvars, dvars, qvars_y, pvars_y, dvars_y): train_gen_op_x = train_op.get_train_gen_op_x() train_disc_op_x = train_op.get_train_disc_op_x() train_gen_op_y = train_op.get_train_gen_op_y() train_disc_op_y = train_op.get_train_disc_op_y() x = model1.get_x() y = model1.get_y() z = model1.get_z() d1 = model1.get_d1() d2 = model1.get_d2() FG_x = [] FG_y = [] FD_x = [] FD_y = [] DG_xz = DG() DG_xz.initial() DG_yz = DG() DG_yz.initial() dmb1 = [[1]*2]*128 dmb2 = [[0]*2]*128 for epoch in tqdm( range(n_epoch), total=n_epoch): X_dataset = shuffle(X_dataset) Y_dataset = shuffle(Y_dataset) Z_dataset = shuffle(Z_dataset) i = 0 #print(dmb) for xmb, ymb, zmb in iter_data(X_dataset, Y_dataset, Z_dataset, size=batch_size): #print(xmb) i = i + 1 for _ in range(1): f_d_x, _ = sess.run([model1.get_disc_loss_x(), train_disc_op_x], feed_dict={x: xmb, y:ymb, z:zmb, d1:dmb1, d2:dmb2}) for _ in range(5): f_g_x, _ = sess.run([[model1.get_gen_loss_x(), model1.get_gen_loss_xz(), model1.get_cost_x(), model1.get_cost_xz()], train_gen_op_x], feed_dict={x: xmb, y:ymb, z:zmb, d1:dmb1, d2:dmb2}) FG_x.append(f_g_x) FD_x.append(f_d_x) for _ in range(1): f_d_y, _ = sess.run([model1.get_disc_loss_y(), train_disc_op_y], feed_dict={x: xmb, y:ymb, z:zmb, d1:dmb1, d2:dmb2}) for _ in range(5): f_g_y, _ = sess.run([[model1.get_gen_loss_y(), model1.get_gen_loss_yz(), model1.get_cost_y(), model1.get_cost_yz()], train_gen_op_y], feed_dict={x: xmb, y:ymb, z:zmb, d1:dmb1, d2:dmb2}) FG_y.append(f_g_y) FD_y.append(f_d_y) print_xz(epoch, i, f_d_x, f_g_x[0], f_g_x[1], f_g_x[2], f_g_x[3]) print_yz(epoch, i, f_d_y, f_g_y[0], f_g_y[1], f_g_y[2], f_g_y[3]) DG_xz.set_FD(FD_x) DG_xz.set_FG(FG_x) DG_yz.set_FD(FD_y) DG_yz.set_FG(FG_y) return sess, DG_xz, DG_yz, model1
feed_dict={ x: xmb, y: ymb, z: zmb }) for _ in range(5): f_g_y, _ = sess.run( [[gen_loss_y, gen_loss_yz, cost_y, cost_yz], train_gen_op_y], feed_dict={ x: xmb, y: ymb, z: zmb }) FG_y.append(f_g_y) FD_y.append(f_d_y) print_xz(epoch, i, f_d_x, f_g_x[0], f_g_x[1], f_g_x[2], f_g_x[3]) print_yz(epoch, i, f_d_y, f_g_y[0], f_g_y[1], f_g_y[2], f_g_y[3]) DG_xz.set_FD(FD_x) DG_xz.set_FG(FG_x) DG_yz.set_FD(FD_y) DG_yz.set_FG(FG_y) q_xz = x_inference_network(x, latent_dim, n_layer_inf, n_hidden_inf, eps_dim) p_y = y_generative_network(q_xz, input_dim, n_layer_gen, n_hidden_gen, eps_dim) q_yz = y_inference_network(y, latent_dim, n_layer_inf, n_hidden_inf, eps_dim) p_x = x_generative_network(q_yz, input_dim, n_layer_gen, n_hidden_gen, eps_dim) decoder_logit_x = x_data_network(x, q_xz,