我真的对这种方法非常困惑,特别是当我发现这个令人费解的声明时:
This operation concatenates queue-element component tensors along
the 0th dimension to make a single component tensor. If the queue
has not been closed, all of the components in the dequeued tuple
will have size `n` in the 0th dimension.
以下是一些评论作为方法的描述:
TensorShape([None])
在形状的第0维度指定无(我想它可能是n?)是很奇怪的,这似乎与 size' n' 相矛盾在描述中。这导致我的程序出现形状错误,我无法理解其中的原因,尽管我已经找到了它的位置。
你能告诉我为什么在这里使用RDD[(K, V)]
吗?
答案 0 :(得分:0)
QueueBase.dequeue_up_to(n)
方法从队列中返回最多 (“最多”)n
个元素的批次。相比之下,QueueBase.dequeue_many(n)
方法从队列中返回了一批恰好 n
个元素。
在队列为closed之前,这两个操作的行为相同。此后,不能再将其他元素添加到队列中,因此这些操作将耗尽其余元素。如果剩余元素(num_remaining
)的数量不是n
的精确倍数,则QueueBase.dequeue_up_to(n)
将返回最后一批较小的num_remaining % n
个元素。相比之下,QueueBase.dequeue_many(n)
将不返回最后的几个元素,因为它不能生成一批恰好n
个元素。
由于QueueBase.dequeue_up_to(n)
可以返回静态未知的不同大小的批次(即n
和num_remaining % n
)(因为num_remaining
取决于发生的入队操作数在运行时),其返回值的第一个维度为Dimension(None)
。 Dimension(None)
通常用于指示在每次执行之间可能变化的形状。