Beispiel #1
0
def main():
    # parse arguments
    args = parse_args()
    if args is None:
        exit()

    if args.model_public:
        rtt.set_restore_model(False)
    else:
        rtt.set_restore_model(False, plain_model='P0')

    # open session
    # with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess:
    with tf.Session() as sess:
        start_time = time.time()
        cnn = ResNet(sess, args)

        # build graph
        cnn.build_model()
        print("pystats build_model elapse:{0} s".format(time.time() -
                                                        start_time))

        # show network architecture
        show_all_variables()

        # if args.phase == 'train':
        #     # launch the graph in a session
        #     cnn.train()

        #     print(" [*] Training finished! \n")

        #     cnn.test()
        #     print(" [*] Test finished!")

        if args.phase == 'test':
            start_time = time.time()

            cnn.test(args)
            print("pystats predict elapse:{0} s".format(time.time() -
                                                        start_time))

            print(" [*] Test finished!")
from util import read_dataset

np.set_printoptions(suppress=True)

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

np.random.seed(0)

EPOCHES = 10
BATCH_SIZE = 16
learning_rate = 0.0002

task_id = 'task-id'
rtt.py_protocol_handler.set_loglevel(0)
rtt.activate("Helix", task_id=task_id)
rtt.set_restore_model(['p0', 'p1', 'p2'], task_id=task_id)
#rtt.set_restore_model(['p0', 'p1', 'p2'])
node_id = rtt.get_current_node_id(task_id=task_id)

# real data
# ######################################## difference from tensorflow
file_x = '../dsets/' + node_id + "/reg_test_x.csv"
file_y = '../dsets/' + node_id + "/reg_test_y.csv"
real_X, real_Y = rtt.PrivateDataset(data_owner=(0, 'p9'),
                                    label_owner=1,
                                    task_id=task_id).load_data(file_x,
                                                               file_y,
                                                               header=None)
# ######################################## difference from tensorflow
DIM_NUM = real_X.shape[1]
import tensorflow as tf
import numpy as np
from util import read_dataset

np.set_printoptions(suppress=True)

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

np.random.seed(0)

EPOCHES = 10
BATCH_SIZE = 16
learning_rate = 0.0002

rtt.activate("SecureNN")
rtt.set_restore_model(False, plain_model='P0')
mpc_player_id = rtt.py_protocol_handler.get_party_id()

# real data
# ######################################## difference from tensorflow
file_x = '../dsets/P' + str(mpc_player_id) + "/reg_test_x.csv"
file_y = '../dsets/P' + str(mpc_player_id) + "/reg_test_y.csv"
real_X, real_Y = rtt.PrivateDataset(data_owner=(0, 1),
                                    label_owner=1).load_data(file_x,
                                                             file_y,
                                                             header=None)
# ######################################## difference from tensorflow
DIM_NUM = real_X.shape[1]

X = tf.placeholder(tf.float64, [None, DIM_NUM])
Y = tf.placeholder(tf.float64, [None, 1])
import numpy as np
from util import read_dataset

np.set_printoptions(suppress=True)

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

np.random.seed(0)

EPOCHES = 10
BATCH_SIZE = 16
learning_rate = 0.0002

rtt.py_protocol_handler.set_loglevel(0)
rtt.activate("Helix")
rtt.set_restore_model(['p0', 'p1', 'p2'])
#rtt.set_restore_model(['p0', 'p1', 'p2'])
node_id = rtt.get_current_node_id()

# real data
# ######################################## difference from tensorflow
file_x = '../dsets/' + node_id + "/reg_test_x.csv"
file_y = '../dsets/' + node_id + "/reg_test_y.csv"
real_X, real_Y = rtt.PrivateDataset(data_owner=(0, 'p9'),
                                    label_owner=1).load_data(file_x,
                                                             file_y,
                                                             header=None)
# ######################################## difference from tensorflow
DIM_NUM = real_X.shape[1]

X = tf.placeholder(tf.float64, [None, DIM_NUM])