saikatchatt / danse-jrnl

Data-Driven Nonlinear State Estimation
MIT License
0 stars 1 forks source link

Errors in 'generate_data' and 'loader' #1

Open SongJgit opened 4 months ago

SongJgit commented 4 months ago

https://github.com/saikatchatt/danse-jrnl/blob/e96508528bf57cef540f93cf8c8abd5abb525d2d/bin/generate_data.py#L171-L175 The Xi and Yi returned here seem to be unequal in length(T and T+1), yet np.row_stack only seems to be able to accept data of equal length. As a result, the following error is reported

 File "/home/songj/Workspace/danse-jrnl/./bin/generate_data.py", line 175, in generate_state_observation_pairs
    Z_XY["data"] = np.row_stack(Z_XY_data).astype(object)
  File "/home/songj/miniconda3/envs/dr/lib/python3.10/site-packages/numpy/core/shape_base.py", line 286, in vstack
    arrs = atleast_2d(*tup)
  File "/home/songj/miniconda3/envs/dr/lib/python3.10/site-packages/numpy/core/shape_base.py", line 121, in atleast_2d
    ary = asanyarray(ary)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part

And the use of x.astype(object) here. This makes the following collate_fn problematic as well

File ~/Workspace/danse-jrnl/utils/utils.py:153, in my_collate_fn(batch)
    151 inputs = [item["inputs"] for item in batch]
    152 targets = [item["targets"] for item in batch]
--> 153 targets = torch.from_numpy(np.row_stack(targets))
    154 inputs = torch.from_numpy(np.row_stack(inputs))
    155 return (inputs, targets)

TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.
SongJgit commented 4 months ago

I found the problem, numpy changed the interface in a later version.