Formats a value input for gen_nn_ops.
(value, n, channel_index, name)
| 60 | |
| 61 | |
| 62 | def _get_sequence(value, n, channel_index, name): |
| 63 | """Formats a value input for gen_nn_ops.""" |
| 64 | if value is None: |
| 65 | value = [1] |
| 66 | elif not isinstance(value, collections_abc.Sized): |
| 67 | value = [value] |
| 68 | |
| 69 | current_n = len(value) |
| 70 | if current_n == n + 2: |
| 71 | return value |
| 72 | elif current_n == 1: |
| 73 | value = list((value[0],) * n) |
| 74 | elif current_n == n: |
| 75 | value = list(value) |
| 76 | else: |
| 77 | raise ValueError("{} should be of length 1, {} or {} but was {}".format( |
| 78 | name, n, n + 2, current_n)) |
| 79 | |
| 80 | if channel_index == 1: |
| 81 | return [1, 1] + value |
| 82 | else: |
| 83 | return [1] + value + [1] |
| 84 | |
| 85 | |
| 86 | def _non_atrous_convolution( |
no test coverage detected