Skip to content

Add support for tensors with 0 in shape #567

@dsmilkov

Description

@dsmilkov

TF Python supports tensors that have 0 in their shape (e.g. a 3D tensor with shape [1,0,5]).

Tensors with 0 in their shape have no elements, but broadcasting and concating should still work. E.g. concating [0,N] with [5,N] should return [5,N], and summing [0,N] with [1,N] should give [0,N] (broadcasting 0 with 1 results in 0).

Why have 0 in shapes?
The need arises in real models like ssd_mobilenet_v2_coco where only bounding boxes with confidence above some threshold are retained (see here). Thus, if no boxes have confidence above a threshold, the resulting tensor should be of shape [0, 4] (4 comes from the 4 corners of the bounding box).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions