Open karlzhang-hhg opened 4 years ago
The correct line of code:
result = tfa.metrics.RSquare(dtype=tf.float32, y_shape=(1,))
https://github.com/tensorflow/addons/pull/1310 provides a bit more info why.
@failure-to-thrive describes the intended use. To ease the use of this metric one could possibly implement some opportunistic flattening where this does not lead to ambiguity, like in this case. Not sure if this is worth it. I recognize that this implementation requires some thinking to use correctly, so I raised an issue in tensorflow core that should hopefully in time lead to a more user friendly implementation of RSquare
. https://github.com/tensorflow/tensorflow/issues/40195
Hi @harahu @failure-to-thrive I am having a similar issue even with the extra args being passed in:
ValueError: Shapes must be equal rank, but are 1 and 0 for '{{node ranking_14/AssignAddVariableOp_2}} = AssignAddVariableOp[dtype=DT_FLOAT](ranking_14/AssignAddVariableOp_2/resource, ranking_14/Sum_1)' with input shapes: [], [].
So how to solve it?
ValueError: Shapes must be equal rank, but are 0 and 1 for '{{node AssignAddVariableOp_2}} = AssignAddVariableOp[dtype=DT_FLOAT](AssignAddVariableOp_2/resource, Sum_2)' with input shapes: [], [?].
And the docs does not say what the y_shape
mean.
Nobody can solve this?
Guys, please create a New Issue strictly following the guidelines to provide us a code to reproduce the issue, TF/TFA versions, etc. If you feel your issue somehow related to this one, just refer to it. Simply throwing us error messages will not help in any way, sorry.
So how to solve it?
ValueError: Shapes must be equal rank, but are 0 and 1 for '{{node AssignAddVariableOp_2}} = AssignAddVariableOp[dtype=DT_FLOAT](AssignAddVariableOp_2/resource, Sum_2)' with input shapes: [], [?].
And the docs does not say what the
y_shape
mean.
I just came across this issue, and have no idea how to solve it at the moment. Have you solved it and could you give me some hints? Many thx in advance!
The correct line of code:
result = tfa.metrics.RSquare(dtype=tf.float32, y_shape=(1,))
1310 provides a bit more info why.
@Jichen66 this fixed it for me! Usage in a model:
model.compile(loss='mse', optimizer='adam', metrics=[tfa.metrics.RSquare(dtype=tf.float32, y_shape=(1,))])
System information
Describe the bug Find a bug in tensorflow_addons: In version 0.9.1, the following code wour report error:
However in version 0.8.3, the above code works fine.
A clear and concise description of what the bug is.
Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.
Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.