Skip to content

Commit c7f7f36

Browse files
dydavidkimAdamLang96Brianzheng123
authored
Resizing layer unit test assertion line length exceeded refactored (#58)
* Implementation of preprocessing image resizing layer Important Note: The lower-level op implementation of image resizing-nearest neighbor in TensorFlow.js differs from the implementation of the comparable op in Keras-Python. While the Python version of the op function always selects the bottom right cell of the sub-matrix to be used as the representative value of that region in the downscaled matrix, the JavaScript implementation defaults to the top left cell of the sub-matrix, and then preferentially shifts to the right side of the sub-matrix in all sub-matrices past the lateral halfway point ( calculated by floor((length-1)/2) ), and the bottom side of the sub-matrix in all sub-matrices past the vertical halfway point, when considering the top-left side of the parent matrix as the origin. This causes a slight variation in the output values from nearest neighbor downscaling between the Python and JavaScript versions of the code as it currently stands, and the unit tests for the resizing layer has been implemented to reflect this difference in op-function behavior. Co-authored-by: Adam Lang (@AdamLang96) <[email protected]> Co-authored-by: Brian Zheng (@Brianzheng123) <[email protected]> * Updating image preprocessing test file to include approved usage of CodeSmith licensing header * refactored interpolation type declaration * minor spacing correction * resizing layer test assertion statement argument casting refactored * image resizing layer unit test assertion line max length exceeded refactored Co-authored-by: Adam Lang (@AdamLang96) <[email protected]> Co-authored-by: Brian Zheng (@Brianzheng123) <[email protected]>
1 parent 641c3a6 commit c7f7f36

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tfjs-layers/src/layers/preprocessing/image_resizing_test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ describeMathCPUAndGPU('Resizing Layer', () => {
110110
const incorrectArgs = {height, width, interpolation};
111111
const expectedError =
112112
`Invalid interpolation parameter: ${interpolation} is not implemented`;
113-
expect(() => new Resizing(incorrectArgs as ResizingArgs)).toThrowError(expectedError);
113+
expect(() => new Resizing(incorrectArgs as ResizingArgs))
114+
.toThrowError(expectedError);
114115
});
115116

116117
it('Config holds correct name', () => {

0 commit comments

Comments
 (0)