impl_helper_test.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:transform 作者: tensorflow 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号