Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Data cardinality is ambiguous: #18

Open
vdfdfhgbstdh opened this issue Aug 13, 2020 · 3 comments
Open

ValueError: Data cardinality is ambiguous: #18

vdfdfhgbstdh opened this issue Aug 13, 2020 · 3 comments

Comments

@vdfdfhgbstdh
Copy link

I get this error when running the trading_algo.py:

`ValueError Traceback (most recent call last)
in ()
----> 1 model.predict([[ohlcv], [ind]])

3 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/data_adapter.py in init(self, x, y, sample_weights, sample_weight_modes, batch_size, epochs, steps, shuffle, **kwargs)
280 label, ", ".join(str(i.shape[0]) for i in nest.flatten(data)))
281 msg += "Please provide data which shares the same first dimension."
--> 282 raise ValueError(msg)
283 num_samples = num_samples.pop()
284 `
ValueError: Data cardinality is ambiguous:
x sizes: 50, 1
Please provide data which shares the same first dimension.

Can anyone advise what the issue is?

@OdincoGaming
Copy link

same issue here, saw in some tensorflow threads that its due to inputs with a different number of values, IE ohlcv and ind are different lengths, but I havent found a fix for it yet. ill keep you updated if I find something.

@OdincoGaming
Copy link

so I ran it in a jupyter notebook to get a closer look at the variables and ohlcv_test has lengths of (675, 50, 5) while tech_ind_test has lengths of (675, 1) and the error is returning x size: 50, 1 so it seems to be skipping over the 675 values for both arrays and trying to compare the 50 and the 1. not sure what to do about it, but that seems to be whats happening.

@NicBT
Copy link

NicBT commented Aug 19, 2020

i found the problem and the fix:
In predicted_price_tomorrow = np.squeeze(y_normaliser.inverse_transform(model.predict([[ohlcv], [ind]]))),
model.predict() is expecting (in this case) a list of arrays. Instead, we are currently passing in a list of lists. To fix this, all you need to do is change model.predict([[ohlcv], [ind]]) to model.predict([np.array([ohlcv]), np.array([ind])])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants