Skip to content

Complexity is n! where n is the maximum arity for a fact #3

@faceslog

Description

@faceslog

Hey there,

So, this method is giving me some serious “math anxiety”! In my dataset (WD50k), I’ve got facts with an arity of 67. That means it tries to compute a humble 3.647111091818868e+94 permutations. 😅

To put it mildly, my CPU is now in therapy.

It would be great if there were some way to update the negative sampling or for example fix the maximum number of permutations for facts with an arity that is too big ?

def permutations(arr, position, end, res):
    """
    Permutate the array
    """
    if position == end:
        res.append(tuple(arr))
    else:
        for index in range(position, end):
            arr[index], arr[position] = arr[position], arr[index]
            permutations(arr, position+1, end, res)
            arr[index], arr[position] = arr[position], arr[index]
    return res

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions