Exemple #1
0
 def forward(self, x):
     x = torch.sum(x, dim=1)
     print("sum after axis summing: {}".format(torch.sum(x)))
     print("gaussian map sum: {}".format(
         torch.sum(gaussian_map(x, self.sigma, self.w, self.gpu))))
     x = gaussian_map(x, self.sigma, self.w, self.gpu) * x
     print("sum after gaussian map: {}".format(torch.sum(x)))
     #print("size is: {}".format(x.size()))
     #print("sd is: {}".format(self.sigma))
     return x
 def __init__(self, gpu=False):
     super(Smoothing, self).__init__()
     self.conv = nn.Conv2d(1, 1, 3, bias=False, padding=1)
     self.gpu = gpu
     self.conv.weight = torch.nn.Parameter(gaussian_map(
         torch.rand(3, 3), 1, 1, self.gpu).view(1, 1, 3, 3),
                                           requires_grad=False)
     print(self.conv.weight.size())
 def forward(self, x):
     x = gaussian_map(x, self.sigma, self.w, gpu) * x
     return x