Some error happened when I importFrozenTF by SameDiffI

when I execute " package org.deeplearning4j.modelimportexamples.tf.advanced.bert.BertInferenceExample",some error happened.

the following is error log:

Exception in thread "main" java.lang.UnsupportedOperationException: Cannot get array for ARRAY type SDVariable - use SDVariable.exec or SameDiff.output instead
	at org.nd4j.autodiff.samediff.SameDiff.getArrForVarName(SameDiff.java:747)
	at org.nd4j.imports.graphmapper.tf.TFGraphMapper.initFunctionFromProperties(TFGraphMapper.java:826)
	at org.nd4j.linalg.api.ops.impl.shape.Gather.initFromTensorFlow(Gather.java:99)
	at org.nd4j.imports.graphmapper.tf.TFGraphMapper.importGraph(TFGraphMapper.java:356)
	at org.nd4j.imports.graphmapper.tf.TFGraphMapper.importGraph(TFGraphMapper.java:141)
	at org.nd4j.imports.graphmapper.tf.TFGraphMapper.importGraph(TFGraphMapper.java:87)
	at org.nd4j.imports.graphmapper.tf.TFGraphMapper.importGraph(TFGraphMapper.java:73)
	at org.nd4j.autodiff.samediff.SameDiff.importFrozenTF(SameDiff.java:5751)
	at org.deeplearning4j.examples.mine.learn01.ImportPBFile.main(ImportPBFile.java:12)

Version Information

Please indicate relevant versions, including, if relevant:
<dl4j-master.version>1.0.0-M1.1</dl4j-master.version>
I work on windows10

Additional Information

The model is PB file downloaded from https://dl4jdata.blob.core.windows.net/testresources/bert_mrpc_frozen_v1.zip

@benbenwt please see: UnsupportedOperationException while training and let me know if you have any issues.

Thank you for replying my issue!:slight_smile:
I follow this Tutorials,and I have put necessary files into src/main/resources:

Then,I got this error:

Exception in thread "main" java.lang.IllegalArgumentException: No import process defined for IteratorV2
	at org.nd4j.samediff.frameworkimport.registry.OpMappingRegistry.lookupOpMappingProcess(OpMappingRegistry.kt:129)
	at org.nd4j.samediff.frameworkimport.tensorflow.ir.TensorflowIRNode.<init>(TensorflowIRNode.kt:45)
	at org.nd4j.samediff.frameworkimport.tensorflow.ir.TensorflowIRGraph.nodeList(TensorflowIRGraph.kt:78)
	at org.nd4j.samediff.frameworkimport.ir.IRFunctionsKt.importInfoForEachNodeInGraph(IRFunctions.kt:49)
	at org.nd4j.samediff.frameworkimport.tensorflow.ir.TensorflowIRGraph.importInfoForEachNode(TensorflowIRGraph.kt:152)
	at org.nd4j.samediff.frameworkimport.ImportGraph.importGraph(ImportGraph.kt:227)
	at org.nd4j.samediff.frameworkimport.tensorflow.importer.TensorflowFrameworkImporter.importFromGraph(TensorflowFrameworkImporter.kt:58)
	at org.nd4j.samediff.frameworkimport.tensorflow.importer.TensorflowFrameworkImporter.runImport(TensorflowFrameworkImporter.kt:64)
	at org.deeplearning4j.modelimportexamples.tf.advanced.bert.BertInferenceExample.main(BertInferenceExample.java:81)

this is my revised code:

   File frozenBertPB = new File("D:\\deeplearning4j-examples\\mydownload\\bert_mrpc_frozen_v1", "bert_mrpc_frozen.pb");
        Map<String, TFImportOverride> iterToPlaceholderOverride = overrideIteratorsToPlaceholders();
        TFOpImportFilter filterNodeIterV2 = filterNodeByName("IteratorV2");
        TensorflowFrameworkImporter tensorflowFrameworkImporter = new TensorflowFrameworkImporter();
        SameDiff sd = tensorflowFrameworkImporter.runImport(frozenBertPB.getAbsolutePath(), Collections.emptyMap());

I guess that I should set a filter for Iteratorv2,but I don’t know how to code.

@benbenwt perfect thanks. Since you posted your model, I’ll take a look. I imported a different version of BERT just fine, but may need to add more definitions. Of note here, you did do everything correctly.

Can you file an issue on Sign in to GitHub · GitHub so we can track this and get this fixed? Thanks!

Of course,Thank you very much for your time!I will file an issue on Github.And could you please Give me a link to the model that works fine?

@benbenwt I’ll do you one better and post the converted model for you so you can use the BERT model you’ve already been working with.

OK,I got it.Let’s fix it.:slight_smile: