def bilinear_kernel_1D(ratio, normalize=True):
 T = theano.tensor
 half_kern = T.arange(1, (ratio + 1), dtype=theano.config.floatX)
 kern = T.concatenate([half_kern, half_kern[(-2)::(-1)]])
 if normalize:
  kern /= ratio
 return kern

def bilinear_kernel_1D ( ratio , normalize = True ) : T = theano . tensor half_kern = T . arange ( 1 , ( ratio + 1 ) , dtype = theano . config . floatX ) kern = T . concatenate ( [ half_kern , half_kern [ ( - 2 ) : : ( - 1 ) ] ] ) if normalize : kern /= ratio return kern
compute 1d kernel for bilinear upsampling this function builds the 1d kernel that can be used to upsample a tensor by the given ratio using bilinear interpolation .