Faran Fahandezh commited on
Commit
3c5efcb
·
1 Parent(s): 044e99f

Add application file4

Browse files
house_diffusion/gaussian_diffusion.py CHANGED
@@ -898,7 +898,8 @@ class GaussianDiffusion:
898
  bin_target = bin_target * 256 #-> [0, 256]
899
  bin_target = dec2bin(bin_target.permute([0,2,1]).round().int(), 8)
900
  bin_target = bin_target.reshape([target.shape[0], target.shape[2], 16]).permute([0,2,1])
901
- t_weights = (t<10).cuda().unsqueeze(1).unsqueeze(2)
 
902
  t_weights = t_weights * (t_weights.shape[0]/max(1, t_weights.sum()))
903
  bin_target[bin_target==0] = -1
904
  assert model_output_bin.shape == bin_target.shape
 
898
  bin_target = bin_target * 256 #-> [0, 256]
899
  bin_target = dec2bin(bin_target.permute([0,2,1]).round().int(), 8)
900
  bin_target = bin_target.reshape([target.shape[0], target.shape[2], 16]).permute([0,2,1])
901
+ # t_weights = (t<10).cuda().unsqueeze(1).unsqueeze(2)
902
+ t_weights = (t<10).unsqueeze(1).unsqueeze(2)
903
  t_weights = t_weights * (t_weights.shape[0]/max(1, t_weights.sum()))
904
  bin_target[bin_target==0] = -1
905
  assert model_output_bin.shape == bin_target.shape
house_diffusion/transformer.py CHANGED
@@ -77,7 +77,7 @@ class MultiHeadAttention(nn.Module):
77
  q = q.transpose(1,2)
78
  v = v.transpose(1,2)# calculate attention using function we will define next
79
  #TODO
80
- mask = mask.to('cuda:0')
81
  scores = attention(q, k, v, self.d_k, mask, self.dropout)
82
  # concatenate heads and put through final linear layer
83
  concat = scores.transpose(1,2).contiguous().view(bs, -1, self.d_model)
@@ -232,8 +232,8 @@ class TransformerModel(nn.Module):
232
 
233
  # Different input embeddings (Input, Time, Conditions)
234
  #TODO---------------------------------------------------------------
235
- x = x.to('cuda:0')
236
- timesteps = timesteps.to(x.device)
237
  # print(x.device)
238
 
239
  time_emb = self.time_embed(timestep_embedding(timesteps, self.model_channels))
@@ -247,7 +247,7 @@ class TransformerModel(nn.Module):
247
  else:
248
  cond = th.cat((cond, kwargs[key]), 2)
249
  #TODO
250
- cond = cond.to('cuda:0')
251
  cond_emb = self.condition_emb(cond.float())
252
 
253
  # PositionalEncoding and DM model
 
77
  q = q.transpose(1,2)
78
  v = v.transpose(1,2)# calculate attention using function we will define next
79
  #TODO
80
+ # mask = mask.to('cuda:0')
81
  scores = attention(q, k, v, self.d_k, mask, self.dropout)
82
  # concatenate heads and put through final linear layer
83
  concat = scores.transpose(1,2).contiguous().view(bs, -1, self.d_model)
 
232
 
233
  # Different input embeddings (Input, Time, Conditions)
234
  #TODO---------------------------------------------------------------
235
+ # x = x.to('cuda:0')
236
+ # timesteps = timesteps.to(x.device)
237
  # print(x.device)
238
 
239
  time_emb = self.time_embed(timestep_embedding(timesteps, self.model_channels))
 
247
  else:
248
  cond = th.cat((cond, kwargs[key]), 2)
249
  #TODO
250
+ # cond = cond.to('cuda:0')
251
  cond_emb = self.condition_emb(cond.float())
252
 
253
  # PositionalEncoding and DM model