tensorflow / tensorflow/java

Complex Tensor Implementation Missing?

Open
#494 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
928
Forks
227
PR merge metrics
No merged PRs in 30d

Description

Hi everybody,

i am just simply trying to create a Complex object, and asking myself it is simply not implemented, because i do not find the Class-Type for complex64 or complex128for the Tout parameter for the "df.dtypes.complex" function. In line 5 i just used TFloat32 to get it compiled.

1 Graph g = new Graph();
2 Ops tf = Ops.create(g);
3 Constant r = tf.constant(Float.valueOf((float)5.0));
4 Constant i = tf.constant(Float.valueOf((float)3.0));
5 Complex c = tf.dtypes.complex(r,i, TFloat32.class);

I understand the problem, in line 5:

Exception in thread "main" org.tensorflow.exceptions.TFInvalidArgumentException: Value for attr 'Tout' of double is not in the list of allowed values: complex64, complex128
; NodeDef: {{node Complex}}; Op<name=Complex; signature=real:T, imag:T -> out:Tout; attr=T:type,default=DT_FLOAT,allowed=[DT_FLOAT, DT_DOUBLE]; attr=Tout:type,default=DT_COMPLEX64,allowed=[DT_COMPLEX64, DT_COMPLEX128]>
at org.tensorflow.internal.c_api.AbstractTF_Status.throwExceptionIfNotOK(AbstractTF_Status.java:87)
at org.tensorflow.GraphOperationBuilder.finish(GraphOperationBuilder.java:461)
at org.tensorflow.GraphOperationBuilder.build(GraphOperationBuilder.java:100)
at org.tensorflow.GraphOperationBuilder.build(GraphOperationBuilder.java:71)
at org.tensorflow.op.dtypes.Complex.create(Complex.java:95)
at org.tensorflow.op.DtypesOps.complex(DtypesOps.java:107)
at TensorflowTest.main(TensorflowTest.java:74)

But i do not find a ComplexDataType like TFLoat32

Can anyone bring light into my deepest darkness? I do not find a documentation or an example how it shall be done in java.

Best Regards

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with org.tensorflow.op.dtypes.Complex.java and org.tensorflow.op.DtypesOps.java, then compare the available Java data-type classes with the Complex op signature shown in the report. Check existing Java documentation or examples for complex64 and complex128 usage. Done should either provide supported Java complex types or document the correct way to use the operation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.