csv_coder_test.py 文件源码

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

项目:transform 作者: tensorflow 项目源码 文件源码
def test_valency(self):
    data = ('11|12,"this is a ,text",categorical_value|other_value,1|3,89.0|'
            '91.0,12.0|15.0,False')
    feature_spec = self._INPUT_SCHEMA.as_feature_spec().copy()
    feature_spec['numeric1'] = tf.FixedLenFeature(shape=[2], dtype=tf.int64)
    schema = dataset_schema.from_feature_spec(feature_spec)
    multivalent_columns = ['numeric1', 'numeric2', 'y']
    coder = csv_coder.CsvCoder(self._COLUMNS, schema,
                               delimiter=',', secondary_delimiter='|',
                               multivalent_columns=multivalent_columns)
    expected_decoded = {'category1': ['categorical_value|other_value'],
                        'numeric1': [11, 12],
                        'numeric2': [89.0, 91.0],
                        'boolean1': [False],
                        'text1': 'this is a ,text',
                        'y': ([1, 3], [12.0, 15.0])}
    self._assert_encode_decode(coder, data, expected_decoded)

  # Test successful decoding with a single column.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号