license import { Tensor1D , Tensor4D } from '../tensor' ; import { convertToTensor } from '../tensor_util_env' ; import { TensorLike } from '../types' ; import * as util from '../util' ; import { batchNorm } from './batchnorm' ; import { op } from './operation' ; param x param mean param variance param offset param scale param varianceEpsilon function batchNorm4d_ ( x , mean , variance , offset ? , scale ? , varianceEpsilon ? ) { const $x = convertToTensor ( x , 'x' , 'batchNorm' ) ; const $mean = convertToTensor ( mean , 'mean' , 'batchNorm' ) ; const $variance = convertToTensor ( variance , 'variance' , 'batchNorm' ) ; let $scale ; if ( scale != null ) { $scale = convertToTensor ( scale , 'scale' , 'batchNorm' ) ; } let $offset ; if ( offset != null ) { $offset = convertToTensor ( offset , 'offset' , 'batchNorm' ) ; } util . assert ( $x . rank === 4 , ( ) => `Error in batchNorm4D: x must be rank 4 but got rank ` + `${ $x . rank }.` ) ; util . assert ( $mean . rank === 4 || $mean . rank === 1 , ( ) => `Error in batchNorm4D: mean must be rank 4 or rank 1 but ` + `got rank ${ $mean . rank }.` ) ; util . assert ( $variance . rank === 4 || $variance . rank === 1 , ( ) => `Error in batchNorm4D: variance must be rank 4 or rank 1 ` + `but got rank ${ $variance . rank }.` ) ; if ( $scale != null ) { util . assert ( $scale . rank === 4 || $scale . rank === 1 , ( ) => `Error in batchNorm4D: scale must be rank 4 or rank 1 ` + `but got rank ${ $scale . rank }.` ) ; } if ( $offset != null ) { util . assert ( $offset . rank === 4 || $offset . rank === 1 , ( ) => `Error in batchNorm4D: offset must be rank 4 or rank 1 ` + `but got rank ${ $offset . rank }.` ) ; } return batchNorm ( $x , $mean , $variance , $offset , $scale , varianceEpsilon ) ; } export const batchNorm4d = op ( { batchNorm4d_ } ) ;