Reshapes a >= rank 2 tensor to a rank 2 tensor (i.e., a matrix).
(input_tensor)
| 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).""" |
| 159 | ndims = input_tensor.shape.ndims |
| 160 | if ndims < 2: |
| 161 | raise ValueError("Input tensor must have at least rank 2. Shape = %s" % |
| 162 | (input_tensor.shape)) |
| 163 | if ndims == 2: |
| 164 | return input_tensor |
| 165 | |
| 166 | width = input_tensor.shape[-1] |
| 167 | output_tensor = tf.reshape(input_tensor, [-1, width]) |
| 168 | return output_tensor |
| 169 | |
| 170 | |
| 171 | def reshape_from_matrix(output_tensor, orig_shape_list): |
nothing calls this directly
no outgoing calls
no test coverage detected