示例#1
0
 def graph_fn():
     tf_x = tf.constant([0., 0.5, 1.])
     tf_y = tf.constant([0.6, 0.7, 1.0])
     new_x = tf.constant([0., 0.25, 0.5, 0.75, 1.])
     tf_interpolate_outputs = calibration_builder._tf_linear_interp1d(
         new_x, tf_x, tf_y)
     return tf_interpolate_outputs
 def _get_tf_interp1d(self, new_x, x, y):
     """Helper performing 1d linear interpolation using Tensorflow."""
     with self.test_session() as sess:
         tf_interp_outputs = calibration_builder._tf_linear_interp1d(
             tf.convert_to_tensor(new_x, dtype=tf.float32),
             tf.convert_to_tensor(x, dtype=tf.float32),
             tf.convert_to_tensor(y, dtype=tf.float32))
         np_tf_interp_outputs = sess.run(tf_interp_outputs)
     return np_tf_interp_outputs
 def test_tf_linear_interp1d_map(self):
     """Tests TF linear interpolation mapping to a single number."""
     with self.test_session() as sess:
         tf_x = tf.constant([0., 0.5, 1.])
         tf_y = tf.constant([0.5, 0.5, 0.5])
         new_x = tf.constant([0., 0.25, 0.5, 0.75, 1.])
         tf_map_outputs = calibration_builder._tf_linear_interp1d(
             new_x, tf_x, tf_y)
         tf_map_outputs_np = sess.run([tf_map_outputs])
     self.assertAllClose(tf_map_outputs_np, [[0.5, 0.5, 0.5, 0.5, 0.5]])
示例#4
0
 def graph_fn():
     tf_interp_outputs = calibration_builder._tf_linear_interp1d(
         tf.convert_to_tensor(new_x, dtype=tf.float32),
         tf.convert_to_tensor(x, dtype=tf.float32),
         tf.convert_to_tensor(y, dtype=tf.float32))
     return tf_interp_outputs