(inputs: Tensor<Rank.R3>|Tensor<Rank.R4>,
kwargs: Kwargs)
| 113 | } |
| 114 | |
| 115 | override call(inputs: Tensor<Rank.R3>|Tensor<Rank.R4>, |
| 116 | kwargs: Kwargs): Tensor[]|Tensor { |
| 117 | |
| 118 | return tidy(() => { |
| 119 | const input = getExactlyOneTensor(inputs); |
| 120 | this.imgWidth = input.shape[input.shape.length - 2]; |
| 121 | const imgHeight = input.shape[input.shape.length - 3]; |
| 122 | |
| 123 | this.heightFactor = randomUniform([1], |
| 124 | (1.0 + this.heightLower), (1.0 + this.heightUpper), |
| 125 | 'float32', this.randomGenerator.next() |
| 126 | ); |
| 127 | |
| 128 | let adjustedHeight = this.heightFactor.dataSync()[0] * imgHeight; |
| 129 | adjustedHeight = Math.round(adjustedHeight); |
| 130 | |
| 131 | const size:[number, number] = [adjustedHeight, this.imgWidth]; |
| 132 | |
| 133 | switch (this.interpolation) { |
| 134 | case 'bilinear': |
| 135 | return image.resizeBilinear(inputs, size); |
| 136 | case 'nearest': |
| 137 | return image.resizeNearestNeighbor(inputs, size); |
| 138 | default: |
| 139 | throw new Error(`Interpolation is ${this.interpolation} |
| 140 | but only ${[...INTERPOLATION_METHODS]} are supported`); |
| 141 | } |
| 142 | }); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | serialization.registerClass(RandomHeight); |
nothing calls this directly
no test coverage detected