Skip to content

tf.variable with initial value does not work in eager mode #155

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

Closed
rnett opened this issue Nov 21, 2020 · 2 comments · Fixed by #169
Closed

tf.variable with initial value does not work in eager mode #155

rnett opened this issue Nov 21, 2020 · 2 comments · Fixed by #169

Comments

@rnett
Copy link
Contributor

rnett commented Nov 21, 2020

As the title says, tf.variable with an initial value does not work in eager mode. I'm not sure if it is supposed to, as tf.Variable does in the python api but apparently didn't at first. Interestingly, it's not the variable op that fails, it's the assign:

cannot compute Assign as input #0(zero-based) was expected to be a int32_ref tensor but is a int32 tensor
org.tensorflow.exceptions.TFInvalidArgumentException: cannot compute Assign as input #0(zero-based) was expected to be a int32_ref tensor but is a int32 tensor
	at org.tensorflow.internal.c_api.AbstractTF_Status.throwExceptionIfNotOK(AbstractTF_Status.java:87)
	at org.tensorflow.EagerOperationBuilder.execute(EagerOperationBuilder.java:273)
	at org.tensorflow.EagerOperationBuilder.build(EagerOperationBuilder.java:66)
	at org.tensorflow.EagerOperationBuilder.build(EagerOperationBuilder.java:55)
	at org.tensorflow.op.core.Assign.create(Assign.java:97)
	at org.tensorflow.op.core.Helpers.createVariableWithInit(Helpers.java:51)
	at org.tensorflow.op.Ops.variable(Ops.java:7520)
@Craigacp
Copy link
Collaborator

Craigacp commented Nov 21, 2020

Yeah, that's documented in the javadoc:

* Only supported on Graph sessions as the {@link org.tensorflow.op.core.Assign} op

I couldn't figure out an alternative at the time and needed it for the optimizers work. We should at minimum fix it so it throws a sensible looking exception.

@rnett
Copy link
Contributor Author

rnett commented Nov 21, 2020

Could be done easily enough as part of #154, that's what I was originally going to suggest before I realized it was supported in python eager mode.

I assume the codegen doesn't support custom javadocs on the ops methods (for putting the warning on tf.variable)?

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

Successfully merging a pull request may close this issue.

2 participants