feature_column_ops_test.py 文件源码

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

项目:lsdc 作者: febert 项目源码 文件源码
def testWeightedSparseColumnWithDenseInputTensor(self):
    ids = tf.contrib.layers.sparse_column_with_keys(
        "ids", ["marlo", "omar", "stringer", "rick"])
    ids_tensor = tf.constant([["omar", "stringer"], ["marlo", "rick"]])
    weighted_ids = tf.contrib.layers.weighted_sparse_column(ids, "weights")
    weights_tensor = tf.constant([[10.0, 20.0], [30.0, 40.0]])

    features = {"ids": ids_tensor,
                "weights": weights_tensor}
    logits, _, _ = tf.contrib.layers.weighted_sum_from_feature_columns(
        features, [weighted_ids], num_outputs=5)

    with self.test_session():
      tf.initialize_all_variables().run()
      tf.initialize_all_tables().run()
      self.assertAllEqual(logits.eval().shape, [2, 5])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号