Update deepsets to deal with nans (first version)

This commit is contained in:
Johannes Fischer
2021-07-20 18:23:51 +02:00
parent 226a427436
commit ffdff12ccb

View File

@@ -61,7 +61,7 @@ class DeepSetsModule(nn.Module):
# use negative dynamic_dim since batch dimensions are inserted at the front # use negative dynamic_dim since batch dimensions are inserted at the front
dynamic_dim = -2 dynamic_dim = -2
# iterate over dynamic dimension to apply phi to every instance # iterate over dynamic dimension to apply phi to every instance
latent = tuple(self.phi(instance) for instance in x.unbind(dynamic_dim)) latent = tuple(self.phi(instance) for instance in x.unbind(dynamic_dim) if torch.all(~torch.isnan(instance)))
# stack outputs of phi # stack outputs of phi
latent = torch.stack(latent, dim=dynamic_dim) latent = torch.stack(latent, dim=dynamic_dim)
# apply pooling function to reduce dynamic dimension # apply pooling function to reduce dynamic dimension