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)
评论列表
文章目录