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

how to get a Cartesian product #12608

Closed
3 tasks done
saintthor opened this issue Apr 2, 2019 · 4 comments
Closed
3 tasks done

how to get a Cartesian product #12608

saintthor opened this issue Apr 2, 2019 · 4 comments

Comments

@saintthor
Copy link

saintthor commented Apr 2, 2019

Please make sure that the boxes below are checked before you submit your issue.
If your issue is an implementation question, please ask your question on StackOverflow or on the Keras Slack channel instead of opening a GitHub issue.

Thank you!

  • Check that you are up-to-date with the master branch of Keras. You can update with:
    pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps

  • Check that your version of TensorFlow is up-to-date. The installation instructions can be found here.

  • Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

@saintthor
Copy link
Author

I need a keras layer to do such calculation:

def f( [a, b], [c, d] ):
return [ac, ad, bc, bd]

what is the easiest way?

@paulbonnard
Copy link

@kashyapraval
Copy link

https://www.tensorflow.org/api_docs/python/tf/math/multiply

that would rather return [ac, bd].
matrix multiplication and extending rows there after should help.
[a, b].T X [c, d] that returns a matrix of shape(2,2)
X stands for matrix multiplication

@saintthor
Copy link
Author

https://www.tensorflow.org/api_docs/python/tf/math/multiply

that would rather return [ac, bd].
matrix multiplication and extending rows there after should help.
[a, b].T X [c, d] that returns a matrix of shape(2,2)
X stands for matrix multiplication

thanks. I use K.batch_dot( [[a], [b]], [c,d] ) to do this. is it the easiest way?

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