PhySO icon indicating copy to clipboard operation
PhySO copied to clipboard

AssertionError: Arg new_tokens_idx must be a numpy array of dtype = int,,Can I run it on Wins?

Open likai-1991 opened this issue 1 year ago • 6 comments

likai-1991 avatar Mar 16 '23 02:03 likai-1991

Hi likai-1991,

We have updated the git with a fix for that error. Can you pull the latest main version via git pull and retry ?

Wassim

WassimTenachi avatar Mar 16 '23 03:03 WassimTenachi

Thank you,

I'll try again ------------------ 原始邮件 ------------------ 发件人: "WassimTenachi/PhySO" @.>; 发送时间: 2023年3月16日(星期四) 中午11:10 @.>; @.@.>; 主题: Re: [WassimTenachi/PhySO] AssertionError: Arg new_tokens_idx must be a numpy array of dtype = int,,Can I run it on Wins? (Issue #6)

Hi likai-1991,

We have updated the git with a fix for that error. Can you pull the latest main version via git pull and retry ?

Wassim

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

likai-1991 avatar Mar 16 '23 03:03 likai-1991

I have the same issue on Windows. It starts here.

When Running benchmark.dummy_epoch(X, y, run_config)


AssertionError Traceback (most recent call last) Cell In[49], line 1 ----> 1 benchmark.dummy_epoch(X, y, run_config)

File e:\physo-main\physo\task\benchmark.py:61, in dummy_epoch(X, y, run_config) 46 actions = torch.multinomial(probs*prior, num_samples=1)[:, 0] # (batch_size,) 47 #print("Choosing actions:\n", batch.library.lib_tokens[actions]) 48 49 # # ---- Display ---- (...) 59 60 # ---- Appending actions ---- ---> 61 batch.programs.append(actions) 63 # ---- Display ---- 64 ax0.clear()

File e:\physo-main\physo\physym\program.py:729, in VectPrograms.append(self, new_tokens_idx, forbid_inconsistent_units) 726 # ------------------------------ Check new_tokens_idx ------------------------------ 727 # Type 728 assert type(new_tokens_idx) == np.ndarray, "Arg new_tokens_idx must be a numpy array of dtype = int" --> 729 assert new_tokens_idx.dtype == int, "Arg new_tokens_idx must be a numpy array of dtype = int" 731 # Shape 732 assert new_tokens_idx.shape == (self.batch_size,), "Arg new_tokens_idx must have shape = (batch_size,) = (%i,)"
733 % self.batch_size

AssertionError: Arg new_tokens_idx must be a numpy array of dtype = int

rabbittsh avatar Mar 16 '23 09:03 rabbittsh

It look like you don't have the latest version of the code where this issue was corrected. Can you try to pull the latest version via these command at the root of the PhySO folder: git stash git pull And then retry ?

WassimTenachi avatar Mar 16 '23 13:03 WassimTenachi

I think I updated it. The error is in program.py and I figured it was updated recentely.

rabbittsh avatar Mar 16 '23 13:03 rabbittsh

To check that you were able to properly update it can you check that line 729 of file program.py is now : 729 assert (new_tokens_idx.dtype == int or new_tokens_idx.dtype==np.dtype("int64")), "Arg new_tokens_idx must be a numpy array of dtype = int"

WassimTenachi avatar Mar 16 '23 13:03 WassimTenachi

This is due to how numpy works on windows, see https://stackoverflow.com/questions/36278590/numpy-array-dtype-is-coming-as-int32-by-default-in-a-windows-10-64-bit-machine

This was corrected in the latest version of PhySO.

WassimTenachi avatar Mar 20 '23 14:03 WassimTenachi