-
Notifications
You must be signed in to change notification settings - Fork 188
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
Reshaping array in numpy scrambles values #263
Comments
Once #85 is merged that will provide a good way to do this. |
Here is a minimal reproduction of the issue Converting bit arrays in #85 fails, so it falls back to the other method which doesn't take revdims. |
Does not modify underlying memory Documented: JuliaPy/PyCall.jl#263
eb8d70a adds |
Looks great. Thanks for adding that in! Closing this out. |
In short: Why does reshaping an array on the numpy side touch the underlying memory ([1,2,3,4] -> [1,3,2,4]). I thought it should just require changing the metadata on stride/shape. Is the reshuffling necessary?
I am using PyCall to call into Keras for my project to write a Go bot in Julia. I am running into problems converting arrays for use with Keras.
On the Julia side, the training example array is of size (19, 19, 6, N), corresponding to N examples of 6 layers of 19x19 features. On the Python side, Keras expects the array to be (N, 6, 19, 19).
I have successfully trained models using the following function (in code here) to process arrays before passing them into Keras (
train
simplified. Actual code here).I strongly believe this to be correct because it produces a reasonably strong go bot and achieves good validation accuracy. Unfortunately, it takes an absurd amount of memory and maxes out RAM for large X because it actually reshuffles the underlying data. Stranger still, the order changes if you flatten the array:
--------- ^ important part above ^ ----------
I also experimented with #85 , but it does not seem to help this case. A few things I tried: (each part was fed into
model.fit
to test).to_python
is the only one that actually fits the data. Even though the first two have the correct dimensionality, the data is effectively shuffled and is nonsensical.The text was updated successfully, but these errors were encountered: