def _two_phases_preprocessing_fn(inputs):
    x = inputs['x']
    x_mean = analyzers.mean(x)
    x_square_deviations = tf.square(x - x_mean)
    x_var = analyzers.mean(x_square_deviations + analyzers.mean(inputs['y']))
    x_normalized = (x - x_mean) / tf.sqrt(x_var)
    return {
        'x_normalized': x_normalized,
        's_id': mappers.compute_and_apply_vocabulary(inputs['s'])
    }
Example #2
0
  def test_create_phases_with_table(self):
    # Create a graph with table that can only be run after the first analyzer
    # has run.  Note converting an integerized string into a float doesn't make
    # much sense, but is a legal tensorflow computation.
    string_placeholder = tf.placeholder(tf.string, shape=(None,))
    integerized = mappers.compute_and_apply_vocabulary(string_placeholder)
    integerized = tf.to_float(integerized)
    integerized / analyzers.max(integerized)  # pylint: disable=expression-not-assigned

    phases = impl_helper.create_phases({'x': string_placeholder})
    self.assertEqual(len(phases), 2)
    self.assertEqual(len(phases[0].analyzer_infos), 1)
    self.assertEqual(len(phases[1].analyzer_infos), 1)
    self.assertEqual(len(phases[0].table_initializers), 0)
    self.assertEqual(len(phases[1].table_initializers), 1)