def run_case(data, checkpoint_dir, use_gateway=True): # reshape data to TF format data = np.transpose(data, (0, 2, 3, 1)) # reset the Graph tf.reset_default_graph() # tf Graph input x = tf.placeholder(tf.float32, shape=data.shape) # Construct model pred = concat_conv_net(x, use_gateway) # Transform to the Intel DAAL model model = pydaal.transform(pred) # Initializing the variables init = tf.global_variables_initializer() # Provide a reference path to PyDAAL model pydaal.dump_model(model, checkpoint_dir) # Create a saver saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=0) # Launch the graph with tf.Session() as sess: sess.run(init) checkpoint_path = os.path.join(checkpoint_dir, 'model.ckpt') saver.save(sess, checkpoint_path, global_step=0) predictions = sess.run(pred, feed_dict={x: data}) return predictions
def test_reshape_case(self): test_data = np.random.randn(100, 64, 7, 7) reshape = tf.reshape(tf.constant(test_data), [-1, 7 * 7 * 64]) with tf.Session() as sess: tf_predictions = sess.run(reshape) # Transform to the Intel DAAL model model = pydaal.transform_all() pydaal.dump_model(model, self.checkpoint_dir) self.net.build(self.checkpoint_dir) with self.net.predict(test_data) as predictions: assert_allclose(tf_predictions, predictions, atol=1e-10)
def run_case(data, checkpoint_dir): # reset the Graph tf.reset_default_graph() # tf Graph input x = tf.placeholder(tf.float32) # Construct model pred = activation_net(x) # Launch the graph with tf.Session() as sess: predictions = sess.run(pred, feed_dict={x: data}) # Transform to the Intel DAAL model model = pydaal.transform(pred) # Provide a reference path to PyDAAL model pydaal.dump_model(model, checkpoint_dir) return predictions
def run_case(data, checkpoint_dir): # Network Parameters n_classes = 10 # reset the Graph tf.reset_default_graph() # tf Graph input x = tf.placeholder(tf.float32) dropout = tf.placeholder(tf.float32) # Construct model pred = mlp_net(x, n_classes, dropout) # Transform to the Intel DAAL model model = pydaal.transform_all() # Initializing the variables init = tf.global_variables_initializer() # Create a saver saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=0) # Launch the graph with tf.Session() as sess: sess.run(init) checkpoint_path = os.path.join(checkpoint_dir, 'model.ckpt') saver.save(sess, checkpoint_path, global_step=0) predictions = sess.run(pred, feed_dict={x: data, dropout: 1.}) # Provide a reference path to PyDAAL model pydaal.dump_model(model, checkpoint_dir) return predictions