def train_model2(train_op, n_epoch_2, opt, model1, sess, X_dataset, Y_dataset, W_dataset, Z_dataset): train_gen_op_xyw = train_op.get_train_gen_op_xyw() train_disc_op_xyw = train_op.get_train_disc_op_xyw() FD_xyw = [] FG_xyw = [] DG_xyw = DG() DG_xyw.initial() dmb1 = [[0]*2]*128 dmb2 = [[1]*2]*128 x = model1.get_x() y = model1.get_y() w = model1.get_w() z = model1.get_z() d1 = model1.get_d1() d2 = model1.get_d2() for epoch in tqdm( range(n_epoch_2), total=n_epoch_2): X_dataset = shuffle(X_dataset) Y_dataset = shuffle(Y_dataset) W_dataset = shuffle(W_dataset) Z_dataset = shuffle(Z_dataset) i = 0 for xmb, ymb, wmb, zmb in iter_data(X_dataset, Y_dataset, W_dataset, Z_dataset, size=batch_size): i = i + 1 for _ in range(1): f_d_xyw, _ = sess.run([model1.get_disc_loss_xyw(), train_disc_op_xyw], feed_dict={x: xmb, y:ymb, w:wmb, z:zmb, d1:dmb1, d2:dmb2}) for _ in range(5): f_g_xyw, _ = sess.run([[model1.get_gen_loss_xyw(), model1.get_gen_loss_x(), model1.get_cost_x(), model1.get_cost_xz()], train_gen_op_xyw], feed_dict={x: xmb, y:ymb, w:wmb, z:zmb, d1:dmb1, d2:dmb2}) FG_xyw.append(f_g_xyw) FD_xyw.append(f_d_xyw) print_xy(epoch, i, f_d_xyw, f_g_xyw[0], f_g_xyw[1], f_g_xyw[2], f_g_xyw[3]) DG_xyw.set_FD(FD_xyw) DG_xyw.set_FG(FG_xyw) return sess, DG_xyw, model1
feed_dict={ x: xmb, y: ymb, z: zmb }) for _ in range(5): f_g_xy, _ = sess.run( [[gen_loss, gen_loss_xz, cost_x, cost_xz], train_gen_op_xy], feed_dict={ x: xmb, y: ymb, z: zmb }) FG_xy.append(f_g_xy) FD_xy.append(f_d_xy) print_xy(epoch, i, f_d_xy, f_g_xy[0], f_g_xy[1], f_g_xy[2], f_g_xy[3]) DG_xy.set_FD(FD_xy) DG_xy.set_FG(FG_xy) #[sess,DG_xz,DG_yz,DG_xy]=train(option, sess, data_x.get_dataset(), data_y.get_dataset(), data_z.get_dataset(), print_xz, train_gen_op_xy, train_disc_op_xy, train_gen_op_x, train_disc_op_x, gen_loss_x, disc_loss_x,train_gen_op_y, train_disc_op_y, gen_loss_y, disc_loss_y, x, y, z,gen_loss_xz, cost_x, cost_xz, gen_loss_yz, cost_y, cost_yz, gen_loss_xy, disc_loss_xy, cost_yzxz, cost_xzyz) """ testing the results """ n_viz = 1 [imxz, rmxz, imzx, rmzx, imyz, rmyz, imzy, rmzy, rmyzy, rmxzx] = test(option, data_x.get_dataset_test(), data_y.get_dataset_test(), data_z.get_dataset_test(), q_xz, rec_xz, p_x, q_yz, rec_yz, p_y, rec_zx, rec_zy, n_viz, sess, x, y, z) # print all plot_all(option, DG_xz, DG_yz, DG_xy, imxz, rmxz, imzx, rmzx, imyz, rmyz, imzy, rmzy, rmyzy, rmxzx, data_x.get_label_test(), data_y.get_label_test(), data_z.get_label_test(), n_viz)