MCPcopy Index your code
hub / github.com/tensorflow/tfjs / call

Method call

tfjs-layers/src/layers/preprocessing/random_width.ts:115–143  ·  view source on GitHub ↗
(inputs: Tensor<Rank.R3>|Tensor<Rank.R4>,
    kwargs: Kwargs)

Source from the content-addressed store, hash-verified

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.imgHeight = input.shape[input.shape.length - 3];
121 const imgWidth = input.shape[input.shape.length - 2];
122
123 this.widthFactor = randomUniform([1],
124 (1.0 + this.widthLower), (1.0 + this.widthUpper),
125 'float32', this.randomGenerator.next()
126 );
127
128 let adjustedWidth = this.widthFactor.dataSync()[0] * imgWidth;
129 adjustedWidth = Math.round(adjustedWidth);
130
131 const size:[number, number] = [this.imgHeight, adjustedWidth];
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
146serialization.registerClass(RandomWidth);

Callers

nothing calls this directly

Calls 8

tidyFunction · 0.90
getExactlyOneTensorFunction · 0.90
randomUniformFunction · 0.85
roundMethod · 0.80
resizeBilinearMethod · 0.80
resizeNearestNeighborMethod · 0.80
dataSyncMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected