ml_implementation
ml_implementation copied to clipboard
TypeError: unhashable type: 'State'
Dear Mr/Miss: I have implemented your code, and something wrong happened: TypeError: unhashable type: 'State' Could you please tell me how does this happen and how can I fix it? Thank you. Sincerely Luo
Thanks for your response.
Can you show which script causes this error? How can we re-produce this problem? @sasforce
I have the same problem. my os: win7+python3.6, no cuda.
Dear Mr/Miss:
I have the same problem, the inform shown in the terminal is as follows:
Play round: 1
Traceback (most recent call last):
File "mcst_example.py", line 296, in
Well, after I deleted the "def eq(self, other):" function at 66th line, and the "def repr(self):" at 72th line, this code worked.
Thanks for your response @guanzeying @YOUNG34 .
It would be the issue of compatibility of Python 2.7 and Python 3.0. I will have a look later or just remove the incompatible code.
Just removing the "eq" function is enough, I made a stupid mistake to remove the "repr" function yesterday.
Have a nice day. ?? Outlook for Androidhttps://aka.ms/ghei36
From: tobe [email protected] Sent: Monday, June 4, 2018 2:35:10 AM To: tobegit3hub/ml_implementation Cc: Yang, Ze; Mention Subject: Re: [tobegit3hub/ml_implementation] TypeError: unhashable type: 'State' (#3)
Thanks for your response @guanzeyinghttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fguanzeying&data=01%7C01%7Cze.yang%40kcl.ac.uk%7Cf0449a27c71a46a5522b08d5c9bb69ee%7C8370cf1416f34c16b83c724071654356%7C0&sdata=Kr3XG%2FgoAg1%2BBQyR4mdVT6iLhwTXudtXXnLlH0nTcos%3D&reserved=0 @YOUNG34https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FYOUNG34&data=01%7C01%7Cze.yang%40kcl.ac.uk%7Cf0449a27c71a46a5522b08d5c9bb69ee%7C8370cf1416f34c16b83c724071654356%7C0&sdata=eEj%2F65xB00K7QZPrqgtE7eL2Z08UtMauYhTe73cmcs0%3D&reserved=0 . It would be the issue of compatibility of Python 2.7 and Python 3.0. I will have a look later or just remove the incompatible code.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftobegit3hub%2Fml_implementation%2Fissues%2F3%23issuecomment-394211894&data=01%7C01%7Cze.yang%40kcl.ac.uk%7Cf0449a27c71a46a5522b08d5c9bb69ee%7C8370cf1416f34c16b83c724071654356%7C0&sdata=WbnayGT%2FzTziAM98yZQMMsTNOLX17t7aZj9%2FQw0VAC8%3D&reserved=0, or mute the threadhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAfIEo1iEhwXEkpepVQc4EryLqRC9Q6Oeks5t5I7OgaJpZM4S4TYm&data=01%7C01%7Cze.yang%40kcl.ac.uk%7Cf0449a27c71a46a5522b08d5c9bb69ee%7C8370cf1416f34c16b83c724071654356%7C0&sdata=De4B0EMEpTEL68ik0m5Ofu%2BsBpBm9RRfGagnlhSLcFU%3D&reserved=0.
https://github.com/tobegit3hub/ml_implementation/issues/6#issue-544077431 add below codes will correct the error.
class State(object):
.....
def __eq__(self, other):
if isinstance(other, self.__class__):
return (self.current_value, self.current_round_index, self.cumulative_choices) == \
(other.current_value, other.current_round_index, other.cumulative_choices)
else:
return False
def __hash__(self):
return hash('{},{},{}'.format(self.current_value, self.current_round_index, self.cumulative_choices))