前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >tf.dynamic_partition()

tf.dynamic_partition()

作者头像
狼啸风云
修改2022-09-03 20:53:42
1.1K0
修改2022-09-03 20:53:42
举报

Defined in generated file: python/ops/gen_data_flow_ops.py

Partitions data into num_partitions tensors using indices from partitions.

Aliases:

代码语言:javascript
复制
tf.dynamic_partition(
    data,
    partitions,
    num_partitions,
    name=None
)

For each index tuple js of size partitions.ndim, the slice data[js, ...] becomes part of outputs[partitions[js]]. The slices with partitions[js] = i are placed in outputs[i] in lexicographic order of js, and the first dimension of outputs[i] is the number of entries in partitions equal to i. In detail,

代码语言:javascript
复制
    outputs[i].shape = [sum(partitions == i)] + data.shape[partitions.ndim:]

    outputs[i] = pack([data[js, ...] for js if partitions[js] == i])

data.shape must start with partitions.shape.

For example:

代码语言:javascript
复制
    # Scalar partitions.
    partitions = 1
    num_partitions = 2
    data = [10, 20]
    outputs[0] = []  # Empty with shape [0, 2]
    outputs[1] = [[10, 20]]

    # Vector partitions.
    partitions = [0, 0, 1, 1, 0]
    num_partitions = 2
    data = [10, 20, 30, 40, 50]
    outputs[0] = [10, 20, 50]
    outputs[1] = [30, 40]

See dynamic_stitch for an example on how to merge partitions back.

Args:

  • data: A Tensor.
  • partitions: A Tensor of type int32. Any shape. Indices in the range [0, num_partitions).
  • num_partitions: An int that is >= 1. The number of partitions to output.
  • name: A name for the operation (optional).

Returns:

A list of num_partitions Tensor objects with the same type as data.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-11-25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档