def testCreatePhasesWithTable(self):
# Test a preprocessing function 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.
def preprocessing_fn(inputs):
integerized = mappers.string_to_int(inputs['x'])
integerized = tf.to_float(integerized)
scaled_to_0_1 = integerized / analyzers.max(integerized)
return {'x_scaled': scaled_to_0_1}
input_schema = sch.Schema({
'x': sch.ColumnSchema(tf.string, [], sch.FixedColumnRepresentation())
})
graph, _, _ = impl_helper.run_preprocessing_fn(
preprocessing_fn, input_schema)
phases = impl_helper.create_phases(graph)
self.assertEqual(len(phases), 2)
self.assertEqual(len(phases[0].analyzers), 1)
self.assertEqual(len(phases[1].analyzers), 1)
self.assertEqual(len(phases[0].table_initializers), 0)
self.assertEqual(len(phases[1].table_initializers), 1)
评论列表
文章目录