(tensor, expected_rank=None, name=None)
| 133 | return output |
| 134 | |
| 135 | def get_shape_list(tensor, expected_rank=None, name=None): |
| 136 | if name is None: |
| 137 | name = tensor.name |
| 138 | |
| 139 | if expected_rank is not None: |
| 140 | assert_rank(tensor, expected_rank, name) |
| 141 | |
| 142 | shape = tensor.shape.as_list() |
| 143 | |
| 144 | non_static_indexes = [] |
| 145 | for (index, dim) in enumerate(shape): |
| 146 | if dim is None: |
| 147 | non_static_indexes.append(index) |
| 148 | |
| 149 | if not non_static_indexes: |
| 150 | return shape |
| 151 | |
| 152 | dyn_shape = tf.shape(tensor) |
| 153 | for index in non_static_indexes: |
| 154 | shape[index] = dyn_shape[index] |
| 155 | return shape |
| 156 | |
| 157 | def reshape_to_matrix(input_tensor): |
| 158 | """Reshapes a >= rank 2 tensor to a rank 2 tensor (i.e., a matrix).""" |
no test coverage detected