Skip to content

TypeError: '<' not supported between instances of 'BeamSearchNode' and 'BeamSearchNode' #3

@gionanide

Description

@gionanide

I had this problem. I found out that this happens when in the PriorityQueue(PQ) two elements have the same value then, the algorithm moves to the element itself. Because the element in the PQ is an object it generates this Error.

The solution was that I add in the class a special function to handle this by choosing the element with the highest probability., as follows. If this seems ok to you, you can add this lines in your code. Or I can make a pull request.

#function in the class BeamSearchNode
def __lt__(self, other):
        return self.prob < other.prob

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