Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ def __getitem__(self, index):
class_index = index%self.num_samples
image = torch.tensor(np.array([np.load(self.directory+selected_class+'/%s'%selected_class+self.aux+'%d.npy'%(class_index))]))
if self.aux == '_sim_':
image = (image - torch.min(image))/(torch.max(image)-torch.min(image))
image = (image - torch.min(image))/(torch.max(image)-torch.min(image) + 1e-8)
return image
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def create_sersic(self, source_profile_regenerated, resolution, R_sersic):
x_center_LR, y_center_LR = self.origin_shift(x_center_LR, x/2)*resolution, self.origin_shift(y_center_LR, y/2)*resolution

S_lens = self.sersic_law(theta_x_source.view(1,-1).repeat(B,1), theta_y_source.view(1,-1).repeat(B,1), x_center_LR.view(B,-1), y_center_LR.view(B,-1), R_sersic) #no gradient
S_lens = (S_lens - torch.min(S_lens, dim=-1)[0].view(B,1))/(torch.max(S_lens, dim=-1)[0].view(B,1)-torch.min(S_lens, dim=-1)[0].view(B,1))
S_lens = (S_lens - torch.min(S_lens, dim=-1)[0].view(B,1))/(torch.max(S_lens, dim=-1)[0].view(B,1)-torch.min(S_lens, dim=-1)[0].view(B,1) + 1e-8)
return S_lens

def create_lensing(self, LR, alpha, alpha_interpolated, resolution, resolution_, magnification, R_sersic = None):
Expand Down Expand Up @@ -179,11 +179,11 @@ def create_lensing(self, LR, alpha, alpha_interpolated, resolution, resolution_,
I_lens = self.sersic_law(beta_x_source.view(B,-1), beta_y_source.view(B,-1), x_center_LR.view(B,1), y_center_LR.view(B,1), R_sersic) #gradient flow
S_lens = self.sersic_law(theta_x_source.reshape(1,-1).repeat(B,1), theta_y_source.reshape(1,-1).repeat(B,1), x_center_LR.view(B,-1), y_center_LR.view(B,-1), R_sersic) #no gradient

I_lens_LR = (I_lens_LR - torch.min(I_lens_LR, dim=-1)[0].view(B,1))/(torch.max(I_lens_LR, dim=-1)[0].view(B,1)-torch.min(I_lens_LR, dim=-1)[0].view(B,1))
S_lens = (S_lens - torch.min(S_lens, dim=-1)[0].view(B,1))/(torch.max(S_lens, dim=-1)[0].view(B,1)-torch.min(S_lens, dim=-1)[0].view(B,1))
I_lens = (I_lens - torch.min(I_lens, dim=-1)[0].view(B,1))/(torch.max(I_lens, dim=-1)[0].view(B,1)-torch.min(I_lens, dim=-1)[0].view(B,1))
I_lens_LR = (I_lens_LR - torch.min(I_lens_LR, dim=-1)[0].view(B,1))/(torch.max(I_lens_LR, dim=-1)[0].view(B,1)-torch.min(I_lens_LR, dim=-1)[0].view(B,1) + 1e-8)
S_lens = (S_lens - torch.min(S_lens, dim=-1)[0].view(B,1))/(torch.max(S_lens, dim=-1)[0].view(B,1)-torch.min(S_lens, dim=-1)[0].view(B,1) + 1e-8)
I_lens = (I_lens - torch.min(I_lens, dim=-1)[0].view(B,1))/(torch.max(I_lens, dim=-1)[0].view(B,1)-torch.min(I_lens, dim=-1)[0].view(B,1) + 1e-8)
source_profile_regenerated = source_profile_regenerated.view(B,-1)
source_profile_regenerated = (source_profile_regenerated - torch.min(source_profile_regenerated, dim=-1)[0].view(B,1))/(torch.max(source_profile_regenerated, dim=-1)[0].view(B,1)-torch.min(source_profile_regenerated, dim=-1)[0].view(B,1))
source_profile_regenerated = (source_profile_regenerated - torch.min(source_profile_regenerated, dim=-1)[0].view(B,1))/(torch.max(source_profile_regenerated, dim=-1)[0].view(B,1)-torch.min(source_profile_regenerated, dim=-1)[0].view(B,1) + 1e-8)


I_lens_LR = I_lens_LR.view(B,1,x,y)
Expand Down Expand Up @@ -422,4 +422,4 @@ def forward(self, x):
x = self.fc1(x)
x = self.relu(x)
# x = self.fc2(x)
return torch.nn.functional.sigmoid(x)
return torch.sigmoid(x)