Checks that input is a `float` matrix.
(a, validate_args)
| 640 | |
| 641 | |
| 642 | def _maybe_validate_matrix(a, validate_args): |
| 643 | """Checks that input is a `float` matrix.""" |
| 644 | assertions = [] |
| 645 | if not a.dtype.is_floating: |
| 646 | raise TypeError('Input `a` must have `float`-like `dtype` ' |
| 647 | '(saw {}).'.format(a.dtype.name)) |
| 648 | if a.shape is not None and a.shape.rank is not None: |
| 649 | if a.shape.rank < 2: |
| 650 | raise ValueError('Input `a` must have at least 2 dimensions ' |
| 651 | '(saw: {}).'.format(a.shape.rank)) |
| 652 | elif validate_args: |
| 653 | assertions.append( |
| 654 | check_ops.assert_rank_at_least( |
| 655 | a, rank=2, message='Input `a` must have at least 2 dimensions.')) |
| 656 | return assertions |
| 657 | |
| 658 | |
| 659 | @tf_export('linalg.matrix_rank') |
no test coverage detected