Skip to content
Snippets Groups Projects
Select Git revision
  • ee1741ae39d08ed407b9e6b6b88dccdf8ee91b19
  • master default protected
  • gitkeep
  • dev protected
  • Sprint/2022-01
  • Sprint/2021-15
  • Product/1573-ReadOnlyResources
  • Topic/1594-SetReadOnlyResources
  • Sprint/2021-09
  • Product/1442-projectInviteMngmnt
  • Topic/1529-HandleExternalUserInvitation
  • Topic/1528-projectInviteAPIcon
  • Sprint/2021-07
  • Product/1440-largerFiles
  • Topic/1451-uploadUrl
  • Topic/1452-largerFiles
  • Sprint/2021-06
  • Product/917-maintenanceFunctionality
  • Topic/1297-maintenanceBanner
  • Sprint/2021-04
  • Product/789-userContactEmail
  • v1.31.0
  • v1.30.0
  • v1.29.0
  • v1.28.0
  • v1.27.0
  • v1.26.0
  • v1.25.0
  • v1.24.2
  • v1.24.1
  • v1.24.0
  • v1.23.1
  • v1.23.0
  • v1.22.0
  • v1.21.0
  • v1.20.0
  • v1.19.0
  • v1.18.1
  • v1.18.0
  • v1.17.1
  • v1.17.0
41 results

project-api.ts

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test.py 1.03 KiB
    import torch
    import numpy as np
    from src.data.generators import KSAT_Generator
    from src.csp.csp_data import CSP_Data
    
    # ksat_generator = KSAT_Generator(min_n=3, max_n=3, min_k=2, max_k=2, min_alpha=1.0, max_alpha=1.0)
    #
    # # Create a random Boolean satisfiability instance
    # csp_data_instance = ksat_generator.create_random_instance()
    #
    # logits = torch.ones((csp_data_instance.num_val,), device=csp_data_instance.device, dtype=torch.float32)
    # assignment, _ = csp_data_instance.hard_assign_sample(logits)
    #
    # print("Generated Assignment:", assignment)
    # is_satisfied = csp_data_instance.constraint_is_sat(assignment)
    x = torch.as_tensor([1, 0, 1, 0, 2, 2, 0, 2, 0, 1]).view(2, 5)
    a = x.view(2, 1, -1)
    b = x.view(2, -1, 1)
    print(a)
    c = a == b
    #
    c = c.prod(dim=0)
    rep = torch.tril(c, -1).max(dim=1)[0]
    u = 1 - rep
    rep[rep == 1] = -1
    print(torch.logical_or(u, rep))
    # a = torch.randint(2, size=(2,2,5))
    # print(a)
    # indices = torch.nonzero(a == 1, as_tuple=False)
    
    # Flatten the indices to a 1D tensor
    # flattened_indices = indices.view(-1)
    
    # print(indices)