Like get_shape().as_list(), but explicitly queries the shape of a tensor if necessary to ensure that the returned value contains no unknown value.
(tensor)
| 541 | |
| 542 | |
| 543 | def _get_shape(tensor): |
| 544 | """Like get_shape().as_list(), but explicitly queries the shape of a tensor |
| 545 | if necessary to ensure that the returned value contains no unknown value.""" |
| 546 | |
| 547 | shape = tensor.get_shape().as_list() |
| 548 | none_indices = [i for i, d in enumerate(shape) if d is None] |
| 549 | if none_indices: |
| 550 | # Query the shape if shape contains None values |
| 551 | shape_tensor = array_ops.shape(tensor) |
| 552 | for i in none_indices: |
| 553 | shape[i] = shape_tensor[i] |
| 554 | return shape |
| 555 | |
| 556 | |
| 557 | def _total_size(shape_values): |
no test coverage detected