WassimTenachi/PhySO

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

likai-1991 opened this issue · 7 comments

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

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

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

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 ?

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

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"

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.