如何使用tf.聚集收集价值观?

2024-04-26 14:35:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个带形状的张量'a'(无,851500)。指数张量'b'与形状(无,5)。索引张量是选择轴=1上“a”中的值(该值为85)。预期结果为(无,51500)。你知道吗

但是当我使用tf.gather (a,b)时。我得到的形状是(无,5851500)。你知道吗

当我使用tf.gather (a,b,axis=1)时,我得到了(None,None,51500)

当我使用tf.gather_nd(a,b,)时,出现了一个错误:

ValueError: indices.shape[-1] must be <= params.rank, but saw indices shape: [?,5] and params shape: [?,85,1500] for 'encoder/GatherNd' (op: 'GatherNd') with input shapes: [?,85,1500], [?,5].

有人能帮我吗?谢谢。你知道吗


Tags: nonetf错误paramsbe指数形状shape