Exemple #1
0
def instanceNorm2d(data, scale, bias, epsilon=1e-5):
    batchsize = data.shape[0]
    if batchsize > 1:
        extscale = Utils.tile(scale, batchsize, axis=1)
        extbias = Utils.tile(bias, batchsize, axis=1)

    else:
        extscale = scale
        extbias = bias

    indata = data.reshape(1, batchsize * data.shape[1], data.shape[2],
                          data.shape[3])
    mean = Driver.empty(queue, (1, indata.shape[1], 1, 1),
                        dtype=np.float32,
                        allocator=memPool)
    var = Driver.empty(queue, (1, indata.shape[1], 1, 1),
                       dtype=np.float32,
                       allocator=memPool)

    outdata, savemean, saveinvvar = MIOpen.batchNorm2d(indata,
                                                       extscale,
                                                       extbias,
                                                       mean,
                                                       var,
                                                       epsilon,
                                                       test=False)
    return outdata.reshape(data.shape), savemean, saveinvvar, extscale
Exemple #2
0
 def wrapBatchNormNd(data,
                     scale,
                     bias,
                     mean,
                     var,
                     epsilon,
                     factor,
                     test,
                     mode=None,
                     out=None):
     return MIOpen.batchNorm2d(data,
                               scale,
                               bias,
                               mean,
                               var,
                               epsilon,
                               factor,
                               test,
                               out=out)