-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Description
Remove loops
GaborNet/GaborNet/GaborLayer.py
Lines 103 to 119 in a104371
def calculate_weights(self): | |
for i in range(self.conv_layer.out_channels): | |
for j in range(self.conv_layer.in_channels): | |
sigma = self.sigma[i, j].expand_as(self.y) | |
freq = self.freq[i, j].expand_as(self.y) | |
theta = self.theta[i, j].expand_as(self.y) | |
psi = self.psi[i, j].expand_as(self.y) | |
rotx = self.x * torch.cos(theta) + self.y * torch.sin(theta) | |
roty = -self.x * torch.sin(theta) + self.y * torch.cos(theta) | |
g = torch.exp( | |
-0.5 * ((rotx ** 2 + roty ** 2) / (sigma + self.delta) ** 2) | |
) | |
g = g * torch.cos(freq * rotx + psi) | |
g = g / (2 * math.pi * sigma ** 2) | |
self.conv_layer.weight.data[i, j] = g |
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested