Matrix Multiplication

 

Hello,

while trying to multiply two tables/matrices (elegantly), I seem to have hit a brick wall. So far, I transpose one matrix and apply "Create Collection Column"-nodes to both matrices just to be able to use a Java Snippet to do the multiplication by hand.

 

Somehow I've got the feeling I missed the simple and intuitive approach?

 

Your help is greatly appreciated.
Philip

1 Like

Hi Philip,

 

a simpler approach would be to use the "R Snippet" node which comes with the R plugin. You just need to join the matrices (tables) into one table and let R do the matrix multiplication. Besides, using the R Snippet node you can make use of all the matrix vector operations provided by R easily.

Attached you find an example workflow for matrix multiplications with the R Snippet node.

 

Cheers, Kilian

1 Like

Thanks a lot,
although using the gigantic R-Extension just to realize a matrix multiplication seems over the top. In my humble opinion, it would be great if KNIME would improve w.r.t. to inherent vector and matrix operations.

Does anyone have an update on support for matrix multiplication directly in KNIME?  Searching the web, I came across a package (org.knime.base.util.math) documented here as part of the API, but I can't find any way or place to download as an extension.  This package seems to contain all the linear libraries we have been looking for.

1 Like

Hi,

the package you are referring to is an internal used math library which is not accessible via nodes. We are working on an extension which provides nodes for matrix operations. However our resources are limited and this is not a high priority project. If you are interested in such a plugin please vote for it in this thread and we will update its priority.

Bye,

Tobias

Thanks for the quick reply, Tobias.  How do I vote for a feature?

We monitor all forum posts. So it is sufficient if you state your interest in a particular feature in the corresponding forum post or a new post if none exists already. The more people state their interest in a particular functionality the higher it gets on our priority list.

3 Likes

Any further on a node to do matrix multiply?

Best

David

3 Likes

Hi there @David_Ko,

sry for a later response. This still hasn’t been developed. I have added +1 to ticket to boost it.

Br,
Ivan

1 Like

Hi yes, I would also add my request to this. Basic matrix operations, and things like scalar product would be great.
E.g. the operation
Get weights from a vector (e.g. [[A,B,C],[2,3,4]] and use this to multiply from a different table column A with 2, B with 3 and C with 4) without invoking R would be great.

2 Likes

+1

See also this thread.

Main points: via deeplearning4j knime already has nd4j available which is basically a numpy for java. A first step for me would be a new java snippet node that can operate on the whole table + also has nd4j or similar lib available for fast operations.

As I mentioned in the linked thread, for me it’s not strictly about classic math matrix operations but being able to work on the whole table within java /JVM so not having to pay the serialization penalty which sadly is huge. The combined time of serialization/loading results usually takes more time than the actual calculations.

EDIT: Note that nd4j has gpu (CUDA) support built-in. I mean being able to perform gpu accelerated matrix operations in a GUI / for non-programmers could be a huge selling point. Just saying…

4 Likes

Hi there,

welcome to KNIME Community @christianlangkamp!

Both requests noted :wink:

Br,
Ivan