服务佳的广州网站建设,开发一个交友app多少钱,给网站做游戏视频怎么赚钱,wordpress购买邀请码文章地址:https://arxiv.org/abs/1901.11365 
代码地址: https://github.com/czbiohub-sf/noise2self 
要点   Noise2Self方法不需要信号先验信息、噪声估计信息和干净的训练数据。唯一的假设就是噪声在测量的不同维度上表现出的统计独立性#xff0c;而真实信号表现出一定的… 
文章地址:https://arxiv.org/abs/1901.11365 
代码地址: https://github.com/czbiohub-sf/noise2self 
要点   Noise2Self方法不需要信号先验信息、噪声估计信息和干净的训练数据。唯一的假设就是噪声在测量的不同维度上表现出的统计独立性而真实信号表现出一定的相关性。Noiser2Self根据J-invariant提出了一种噪声校正的方案可以应用到一系列的去噪方法之中提高这些去噪方法的效果。 文章目录 1. 方法原理2. 实验结果2.1 传统校正方法2.2 高斯噪声2.3 不同网络结构对比 3. 代码实现3.1 J-invariant  传统方法3.1 J-invariant  神经网络 4. 总结   1. 方法原理 
如果所研究对象的空间的“潜在维度”远低于测量的维度则可以隐式地学习该结构对测量进行降噪并在没有任何先验知识的情况下恢复信号信号或噪声。 
传统方法问题 
需要对噪声模式进行估计如高斯噪声、结构性噪声那么这些方法的效果就受限于对噪声模式的估计。需要对信号数据的结构有先验估计但是这会限制去噪方法迁移到其他数据集。需要校准因为平滑度、自相似性或矩阵的秩等超参数对去噪方法也会有影响 J-invariant 定义 
假设  j ∈ J j \in J j∈J,  J J J是m维空间, 存在一个函数变换  f ( x ) J : R m ⇒ R m f(x)_J: R^m \Rightarrow R^m f(x)J:Rm⇒Rm。如果这个变换过程不依赖于输入的 x J x_J xJ,那么称这个函数是具有J不变性质。 
换个能看懂的说法信号本身是相关的假设噪声是互不相关的(条件独立的)那么我们用一个方法对这个噪声图片的部分数据进行处理这个处理结果应该是和处理全部数据效果相同的也就是使用部分维度信息达到恢复全局的效果。需要强调的是我自己这里也没有理解特别透彻如果有错误可以提出大家讨论 假设  x x x噪声图片 是  y y y干净图片的无偏估计( E [ x ∣ y ]  y E[x|y]  y E[x∣y]y), 噪声是整个域内是条件独立的那么有  E ∣ ∣ f ( x ) − x ∣ ∣ 2 2  E ∣ ∣ f ( x ) − y ∣ ∣ 2 2  E ∣ ∣ x − y ∣ ∣ 2 2 E||f(x) - x||_2^2  E||f(x) - y||_2^2  E||x - y||_2^2 E∣∣f(x)−x∣∣22E∣∣f(x)−y∣∣22E∣∣x−y∣∣22 
可以看到这里的无监督学习的损失等于 传统的监督学习的损失 加上噪声带来的偏差。 
用J不变性描述一下 Noise2Noise就变为 如果现在有两个观测的噪声数据  x 1  y  n 1 x_1  y  n_1 x1yn1 ,  x 2  y  n 2 x_2  y  n_2 x2yn2。 观测组合:  x  ( x 1 , x 2 ) x  (x_1,x_2) x(x1,x2) 信号组合 y  ( y , y ) ∈ R 2 m y  (y,y) \in R^{2m} y(y,y)∈R2m 如果存在  J  { J 1 , J 2 }  { { 1 , . . . , m } , { m  1 , . . . , 2 m } } J  \{J_1,J_2\}  \{\{1,...,m\},\{m1,...,2m\}\} J{J1,J2}{{1,...,m},{m1,...,2m}},那么有  f J ∗ ( x ) J 2  E [ y ∣ x 1 ] f_{J}^*(x)_{J2}  E[y|x_1] fJ∗(x)J2E[y∣x1] 
就个人理解J-不变性就是一个假设如果噪声是条件独立的那么监督去噪等价于无监督去噪加上一个噪声的偏差影响。 
2. 实验结果 
2.1 传统校正方法 
首先将J不变性应用到 传统方法中 传统的 “median filter”是将半径范围内所有像素的点都替换为中值 这里对比的是一种“donut filter”中值滤波方法用中值替换除了中心像素的所有位置 
那么“median filter”和“donut”甜甜圈模式的滤波器其自监督的损失分别为  ∣ ∣ g r ( x ) − x ∣ ∣ 2 ||g_r(x) - x||^2 ∣∣gr(x)−x∣∣2 ∣ ∣ f r ( x ) − x ∣ ∣ 2 ||f_r(x) - x||^2 ∣∣fr(x)−x∣∣2 
用图绘制出来 从上图可以看出median滤波器监督学习的损失随着半径的增加而线性增加而donut滤波器在r  3的时候其损失有一个最佳值。蓝色实线和蓝色虚线的垂直距离其实表征的是噪声带来的偏差那么我们就发现了对于传统的滤波器我们只能够更改输入来进行调整滤波效果但是对于donut这类具有J-invariant性质的滤波器我们可以通过一些原则来调整滤波效果比如这里的距离r 
那么就可以给定一个比较通用的新滤波器形式了  f θ ( x ) J :  g θ ( 1 J . s ( x )  1 J c . x ) J f_{\theta}(x)_J : g_{\theta}(1_J . s(x)  1_{Jc} . x)_J fθ(x)J:gθ(1J.s(x)1Jc.x)J 
这里的 g θ g_{\theta} gθ表示传统的滤波其 s ( x ) s(x) s(x)表示将一些像素替换为周围其他像素的值/均值的一个操作。 
个人理解和Noise2Void那种盲点去噪的感觉相同都是将输入的某些值进行替换然后恢复那个点的信息。如果将这种方法应用到传统方法中可以帮我们找到最佳的滤波参数。 
2.2 高斯噪声 2.3 不同网络结构对比 3. 代码实现 
相关代码参考: https://github.com/czbiohub-sf/noise2self 
3.1 J-invariant  传统方法 
这里以使用 J-invariant 到 中值滤波为例 加载相关库和数据 
import sys
sys.path.append(..)
import numpy as np
import matplotlib.pyplot as plt
from skimage.morphology import disk
from skimage.filters import gaussian, median
from skimage import data, img_as_float, img_as_ubyte
from skimage.color import gray2rgb
from skimage.util import random_noise
from skimage.metrics import structural_similarity as ssim
from skimage.metrics import peak_signal_noise_ratio as psnr
from skimage.metrics import mean_squared_error as mse
from util import plot_grid, plot_images, expand# 加载原始数据
plt.rc(figure, figsize  (5,5))
show  lambda x: plt.imshow(x, cmapplt.cm.gray)
image  data.camera()
show(image)
plt.show()# 加噪原始数据
np.random.seed(3)
noisy_image  img_as_ubyte(random_noise(image, mode  gaussian, var0.01))
show(noisy_image)
plt.show()定义中值滤波和donut中值滤波方法引入J-invariant 
def mask_center(x):x[len(x)//2,len(x)//2]  0return xplot_images([1-disk(4), 1-mask_center(disk(4))])滤波并进行对比 
radii  range(1, 7)
mask_med  np.array([median(noisy_image, mask_center(disk(i))) for i in radii])
med  np.array([median(noisy_image, disk(i)) for i in radii])plt.figure(figsize(18,6))
for i in range(1,7):plt.subplot(2,6,i)show(mask_med[i-1])plt.title(r{}.format(radii[i-1]))if i 1:plt.ylabel(donut)for i in range(1,7):plt.subplot(2,6,6i)show(med[i-1])if i 1:plt.ylabel(median filter)plt.show()统计损失及相关参考指标 
def stats(im_list, noisy_img, img):img  img_as_float(img)noisy_img  img_as_float(noisy_img)im_list  [img_as_float(x) for x in im_list]loss  [mse(x, noisy_img) for x in im_list]mse_gt  [mse(x, img) for x in im_list]psnr_gt  [psnr(x, img) for x in im_list]return loss, mse_gt, psnr_gtloss_med, mse_med, psnr_med  stats(med, noisy_image, image)
loss_mask_med, mse_mask_med, psnr_mask_med  stats(mask_med, noisy_image, image)
opt  radii[np.argmin(loss_mask_med)]plt.figure(figsize(7,5))plt.plot(radii, loss_mask_med, label  self-supervised, donut median, color  C0)
plt.plot(radii, loss_med, label  self-supervised, ordinary median, color  C1)plt.axvline(radii[np.argmin(loss_mask_med)], colork, linestyle--)
plt.title(Calibrating a Median Filter)plt.plot(radii, mse_mask_med, label  reconstruction error, donut median, color  C0, linestyle--)
plt.plot(radii, mse_med, label  reconstruction error, ordinary median, color  C1, linestyle--)
plt.ylabel(MSE)
plt.xlabel(Radius of Median Filter)plt.yticks([0.002, 0.012])
plt.ylim(0, 0.0143)
plt.legend(loccenter right)
plt.show()加入J-invariant之后可以帮助我们找到最佳的滤波参数此处r  3 
3.1 J-invariant  神经网络 
加载库及数据 
from util import show, plot_images, plot_tensors
from torchvision.datasets import MNIST
from torchvision import transforms
from torch.utils.data import Datasetmnist_train  MNIST(root/data/mnist/, download  True,transform  transforms.Compose([transforms.ToTensor(),]), train  True)mnist_test  MNIST(/data/mnist/, download  True,transform  transforms.Compose([transforms.ToTensor(),]), train  False)定义加噪方法 
from torch import randn
def add_noise(img):return img  randn(img.size())*0.4class SyntheticNoiseDataset(Dataset):def __init__(self, data, modetrain):self.mode  modeself.data  datadef __len__(self):return len(self.data)def __getitem__(self, index):img  self.data[index][0]return add_noise(img), img
noisy_mnist_train  SyntheticNoiseDataset(mnist_train, train)
noisy_mnist_test  SyntheticNoiseDataset(mnist_test, test)
noisy, clean  noisy_mnist_train[0]
plot_tensors([noisy[0], clean[0]], [Noisy Image, Clean Image])加mask也就是加盲点需要恢复的也是这些盲点的信息 
class Masker():Object for masking and demaskingdef __init__(self, width3, modezero, infer_single_passFalse, include_mask_as_inputFalse):self.grid_size  widthself.n_masks  width ** 2self.mode  modeself.infer_single_pass  infer_single_passself.include_mask_as_input  include_mask_as_inputdef mask(self, X, i):phasex  i % self.grid_sizephasey  (i // self.grid_size) % self.grid_sizemask  pixel_grid_mask(X[0, 0].shape, self.grid_size, phasex, phasey)mask  mask.to(X.device)mask_inv  torch.ones(mask.shape).to(X.device) - maskif self.mode  interpolate:masked  interpolate_mask(X, mask, mask_inv)elif self.mode  zero:masked  X * mask_invelse:raise NotImplementedErrorif self.include_mask_as_input:net_input  torch.cat((masked, mask.repeat(X.shape[0], 1, 1, 1)), dim1)else:net_input  maskedreturn net_input, maskdef __len__(self):return self.n_masksdef infer_full_image(self, X, model):if self.infer_single_pass:if self.include_mask_as_input:net_input  torch.cat((X, torch.zeros(X[:, 0:1].shape).to(X.device)), dim1)else:net_input  Xnet_output  model(net_input)return net_outputelse:net_input, mask  self.mask(X, 0)net_output  model(net_input)acc_tensor  torch.zeros(net_output.shape).cpu()for i in range(self.n_masks):net_input, mask  self.mask(X, i)net_output  model(net_input)acc_tensor  acc_tensor  (net_output * mask).cpu()return acc_tensordef pixel_grid_mask(shape, patch_size, phase_x, phase_y):A  torch.zeros(shape[-2:])for i in range(shape[-2]):for j in range(shape[-1]):if (i % patch_size  phase_x and j % patch_size  phase_y):A[i, j]  1return torch.Tensor(A)def interpolate_mask(tensor, mask, mask_inv):device  tensor.devicemask  mask.to(device)kernel  np.array([[0.5, 1.0, 0.5], [1.0, 0.0, 1.0], (0.5, 1.0, 0.5)])kernel  kernel[np.newaxis, np.newaxis, :, :]kernel  torch.Tensor(kernel).to(device)kernel  kernel / kernel.sum()filtered_tensor  torch.nn.functional.conv2d(tensor, kernel, stride1, padding1)return filtered_tensor * mask  tensor * mask_invmasker  Masker(width  4, modeinterpolate)
net_input, mask  masker.mask(noisy.unsqueeze(0), 0)
plot_tensors([mask, noisy[0], net_input[0], net_input[0] - noisy[0]],[Mask, Noisy Image, Neural Net Input, Difference])加载网络模型和进行训练 
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import MSELoss
from torch.optim import Adam
from torch.utils.data import DataLoader
from tqdm import tqdm
from models.modules import ConvBlockclass BabyUnet(nn.Module):def __init__(self, n_channel_in1, n_channel_out1, width16):super(BabyUnet, self).__init__()self.pool1  nn.MaxPool2d(kernel_size2)self.pool2  nn.MaxPool2d(kernel_size2)self.up1  lambda x: F.interpolate(x, modebilinear, scale_factor2, align_cornersFalse)self.up2  lambda x: F.interpolate(x, modebilinear, scale_factor2, align_cornersFalse)self.conv1  ConvBlock(n_channel_in, width)self.conv2  ConvBlock(width, 2*width)self.conv3  ConvBlock(2*width, 2*width)self.conv4  ConvBlock(4*width, 2*width)self.conv5  ConvBlock(3*width, width)self.conv6  nn.Conv2d(width, n_channel_out, 1)def forward(self, x):c1  self.conv1(x)x  self.pool1(c1)c2  self.conv2(x)x  self.pool2(c2)x  self.conv3(x)x  self.up1(x)x  torch.cat([x, c2], 1)x  self.conv4(x)x  self.up2(x)x  torch.cat([x, c1], 1)x  self.conv5(x)x  self.conv6(x)return x
model  BabyUnet()
loss_function  MSELoss()
optimizer  Adam(model.parameters(), lr0.001)data_loader  DataLoader(noisy_mnist_train, batch_size32, shuffleTrue)pbar  tqdm(data_loader)for i, batch in enumerate(pbar):noisy_images, clean_images  batchnet_input, mask  masker.mask(noisy_images, i)net_output  model(net_input)loss  loss_function(net_output*mask, noisy_images*mask)optimizer.zero_grad()loss.backward()optimizer.step()pbar.set_description(Iter:{},loss:{}.format(i,loss.item()))# if i % 10  0:#     print(Loss (, i, ): \t, round(loss.item(), 4))if i  100:break测试训练效果 
test_data_loader  DataLoader(noisy_mnist_test,batch_size32,shuffleFalse,num_workers3)
i, test_batch  next(enumerate(test_data_loader))
noisy, clean  test_batch
simple_output  model(noisy)
invariant_output  masker.infer_full_image(noisy, model)
idx  3
plot_tensors([clean[idx], noisy[idx], simple_output[idx], invariant_output[idx]],[Ground Truth, Noisy Image, Single Pass Inference, J-Invariant Inference])盲点网络训练后使用不同的输入加盲点或者不加得到的效果有些许差别但是整体的去噪效果还可以。 4. 总结 
引入J-invariant的概念到去噪工作之中通过测试对比发现这种方法的自监督比传统方法有更好的效果可以帮助传统方法寻找最佳的调整参数J-invariant的思路可以应用到传统去噪方法中或者先前的无监督、自监督学习工作之中提高效果。对比了Noise2Noiser和Noiser2Void方法和Noise2Void有异曲同工之妙分析原理都是使用盲点网络的思想对输入数据进行mask然后使用网络恢复这些盲点位置的信息。所以也存在和盲点网络相同的问题 损失了盲点位置的信息盲点网络的假设噪声是条件不相关的信号是相关的对于结构性的噪声的效果会较差。噪声零均值假设等假设限制了该方法应用到实际数据之中。  文章转载自: http://www.morning.wglhz.cn.gov.cn.wglhz.cn http://www.morning.fkyrk.cn.gov.cn.fkyrk.cn http://www.morning.rttxx.cn.gov.cn.rttxx.cn http://www.morning.ydnxm.cn.gov.cn.ydnxm.cn http://www.morning.fhkr.cn.gov.cn.fhkr.cn http://www.morning.pwppk.cn.gov.cn.pwppk.cn http://www.morning.mslsn.cn.gov.cn.mslsn.cn http://www.morning.mhbcy.cn.gov.cn.mhbcy.cn http://www.morning.jthjr.cn.gov.cn.jthjr.cn http://www.morning.hsgxj.cn.gov.cn.hsgxj.cn http://www.morning.kjmcq.cn.gov.cn.kjmcq.cn http://www.morning.pszw.cn.gov.cn.pszw.cn http://www.morning.nrll.cn.gov.cn.nrll.cn http://www.morning.lyldhg.cn.gov.cn.lyldhg.cn http://www.morning.tbjtm.cn.gov.cn.tbjtm.cn http://www.morning.skmzm.cn.gov.cn.skmzm.cn http://www.morning.yrsg.cn.gov.cn.yrsg.cn http://www.morning.rycbz.cn.gov.cn.rycbz.cn http://www.morning.nktxr.cn.gov.cn.nktxr.cn http://www.morning.gcqkb.cn.gov.cn.gcqkb.cn http://www.morning.tbhf.cn.gov.cn.tbhf.cn http://www.morning.schwr.cn.gov.cn.schwr.cn http://www.morning.fjshyc.com.gov.cn.fjshyc.com http://www.morning.bynf.cn.gov.cn.bynf.cn http://www.morning.jsrnf.cn.gov.cn.jsrnf.cn http://www.morning.fzlk.cn.gov.cn.fzlk.cn http://www.morning.tlrxp.cn.gov.cn.tlrxp.cn http://www.morning.kehejia.com.gov.cn.kehejia.com http://www.morning.jxtbr.cn.gov.cn.jxtbr.cn http://www.morning.nbsfb.cn.gov.cn.nbsfb.cn http://www.morning.jhgxh.cn.gov.cn.jhgxh.cn http://www.morning.kzcz.cn.gov.cn.kzcz.cn http://www.morning.qgghj.cn.gov.cn.qgghj.cn http://www.morning.kmjbs.cn.gov.cn.kmjbs.cn http://www.morning.rntby.cn.gov.cn.rntby.cn http://www.morning.xhlht.cn.gov.cn.xhlht.cn http://www.morning.qbrs.cn.gov.cn.qbrs.cn http://www.morning.hlyfn.cn.gov.cn.hlyfn.cn http://www.morning.addai.cn.gov.cn.addai.cn http://www.morning.rlkgc.cn.gov.cn.rlkgc.cn http://www.morning.beeice.com.gov.cn.beeice.com http://www.morning.mgmqf.cn.gov.cn.mgmqf.cn http://www.morning.xknsn.cn.gov.cn.xknsn.cn http://www.morning.qzpkr.cn.gov.cn.qzpkr.cn http://www.morning.hpprx.cn.gov.cn.hpprx.cn http://www.morning.mplld.cn.gov.cn.mplld.cn http://www.morning.ctswj.cn.gov.cn.ctswj.cn http://www.morning.nhzxr.cn.gov.cn.nhzxr.cn http://www.morning.crkhd.cn.gov.cn.crkhd.cn http://www.morning.ghgck.cn.gov.cn.ghgck.cn http://www.morning.npfrj.cn.gov.cn.npfrj.cn http://www.morning.rhkmn.cn.gov.cn.rhkmn.cn http://www.morning.kaylyea.com.gov.cn.kaylyea.com http://www.morning.ssxlt.cn.gov.cn.ssxlt.cn http://www.morning.qbzdj.cn.gov.cn.qbzdj.cn http://www.morning.fbzdn.cn.gov.cn.fbzdn.cn http://www.morning.jrrqs.cn.gov.cn.jrrqs.cn http://www.morning.xpzgg.cn.gov.cn.xpzgg.cn http://www.morning.synlt.cn.gov.cn.synlt.cn http://www.morning.llgpk.cn.gov.cn.llgpk.cn http://www.morning.jcjgh.cn.gov.cn.jcjgh.cn http://www.morning.tzrmp.cn.gov.cn.tzrmp.cn http://www.morning.sbrjj.cn.gov.cn.sbrjj.cn http://www.morning.qclmz.cn.gov.cn.qclmz.cn http://www.morning.sjwws.cn.gov.cn.sjwws.cn http://www.morning.kljhr.cn.gov.cn.kljhr.cn http://www.morning.rzscb.cn.gov.cn.rzscb.cn http://www.morning.rlxnc.cn.gov.cn.rlxnc.cn http://www.morning.qlkzl.cn.gov.cn.qlkzl.cn http://www.morning.smzr.cn.gov.cn.smzr.cn http://www.morning.kcrw.cn.gov.cn.kcrw.cn http://www.morning.jrlgz.cn.gov.cn.jrlgz.cn http://www.morning.zrjzc.cn.gov.cn.zrjzc.cn http://www.morning.hxxzp.cn.gov.cn.hxxzp.cn http://www.morning.thxfn.cn.gov.cn.thxfn.cn http://www.morning.gagapp.cn.gov.cn.gagapp.cn http://www.morning.jhkzl.cn.gov.cn.jhkzl.cn http://www.morning.gxcit.com.gov.cn.gxcit.com http://www.morning.djpps.cn.gov.cn.djpps.cn http://www.morning.wdwfm.cn.gov.cn.wdwfm.cn