歡迎來到《圣博凱斯》變頻供水設(shè)備官網(wǎng)
精銳于專業(yè) / 卓然于品質(zhì) -- 20年專注于供水行業(yè),締造至臻品質(zhì) -- 服務(wù)熱線:0731-85783205 18932453205

frernd_FRN的實現(xiàn)TensorFlow and pytorch

import tensorflow as tfdef FRNLayer(x,tua,beta,gamma,eps=1e-6): """ :param x: input tensor:[BHWC] :param tua: [1,1,1,C] :param beta: [1,1,1,C] :param gamma: [1,1,1,C] :param eps: :return: """ nu2 = tf.reduce_mean(tf.square(x),axis=[1,2], keepdims=True) x = x * tf.rsqrt(nu2 + tf.abs(eps)) return tf.maximum(gamma * x + beta,tua)import torchdef FRN(x,tua,beta,gamma,eps=1e-6): nu2 = torch.mean(torch.square(x),dim=[1,2], keepdim=True) x = x * torch.rsqrt(nu2 + torch.abs(eps)) return torch.maximum(gamma * x + beta,tua)

猜你喜歡

18932453205