TypeError: '<' not supported between instances of 'BeamSearchNode' and 'BeamSearchNode'
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
@gionanide Hey bro,I think this is the property of the class "PriorityQueue". If you want to use it with the class you define by yourself, you may want to override the it method. Anyway, just some supplement~
Thanks, I was getting this issue too. On python 3.7 and the current version of the code I had to change this method to:
def __lt__(self, other):
return self.logp < other.logp