java icon indicating copy to clipboard operation
java copied to clipboard

NameScope interacts poorly with subscoping

Open Craigacp opened this issue 3 years ago • 2 comments
trafficstars

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04 x86_64): macOS x86_64
  • TensorFlow installed from (source or binary): source
  • TensorFlow version (use command below): 0.5.0-SNAPSHOT
  • Java version (i.e., the output of java -version): JDK 11

Describe the current behavior I'm trying to debug test failures in tensorflow-framework, and noticed that the test sessions use tf = Ops.create(graph).withName("test");. This makes all the nodes have the name "test_" which makes things pretty tricky to debug. I changed it to tf = Ops.create(graph).withSubScope("test");, but now I'm getting test failures out of the optimizers with the following message:

[INFO] Running org.tensorflow.framework.optimizers.FtrlTest
[ERROR] Tests run: 5, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0.455 s <<< FAILURE! - in org.tensorflow.framework.optimizers.FtrlTest
[ERROR] testFtrlWithL1  Time elapsed: 0.415 s  <<< ERROR!
java.lang.IllegalArgumentException: invalid name: 'test/var0_gradient_accumulator' does not match the regular expression [A-Za-z0-9.][A-Za-z0-9_.\-]*
	at org.tensorflow.framework.optimizers.FtrlTest.testFtrlWithL1(FtrlTest.java:166)

Describe the expected behavior

No test failures, and test nodes have the correct op names.

Code to reproduce the issue Make the withSubScope change at line 44 in org.tensorflow.framework.utils.GraphTestSession.

Craigacp avatar Feb 11 '22 19:02 Craigacp

Here's another issue related to name scoping, are they related? https://github.com/tensorflow/java/issues/397

karllessard avatar Feb 12 '22 15:02 karllessard

I think #397 was fixed by the name import logic that was added in one of @rnett's PRs.

Craigacp avatar Feb 12 '22 15:02 Craigacp