feature_column_ops_test.py 文件源码

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

项目:lsdc 作者: febert 项目源码 文件源码
def testOneHotColumnFromSparseColumnWithHashBucketSucceedsForDNN(self):
    hashed_sparse = tf.contrib.layers.sparse_column_with_hash_bucket("feat", 10)
    wire_tensor = tf.SparseTensor(
        values=["a", "b", "c1", "c2"],
        indices=[[0, 0], [1, 0], [2, 0], [2, 1]],
        shape=[3, 2])
    features = {"feat": wire_tensor}
    one_hot_sparse = tf.contrib.layers.one_hot_column(hashed_sparse)
    output = tf.contrib.layers.input_from_feature_columns(features,
                                                          [one_hot_sparse])
    with self.test_session():
      tf.initialize_all_variables().run()
      tf.initialize_all_tables().run()
      self.assertAllEqual([3, 10], output.eval().shape)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号