tensorflow: Warming tensorflow: Entity could not be transformed and will be executed as-is.

System information

  • Custom layers of tf.layer.Layers
  • Linux Ubuntu 16.04)
  • TensorFlow installed from: Conda
  • TensorFlow version: 1.14
  • Python version: 3.7
  • CUDA/cuDNN version: 10.0.130/7.6.0
  • GPU model and memory: Nvidia TitanX 1080Ti, 12GB

a Snippet of Error message

ERROR:tensorflow:Error converting <bound method EmbeddingSharedWeights.call of <model.EmbeddingSharedWeights object at 0x7fede45b6828>> Traceback (most recent call last): File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/impl/api.py”, line 524, in to_graph return conversion.convert(entity, program_ctx) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/impl/conversion.py”, line 306, in convert entity, program_ctx, free_nonglobal_var_names) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/impl/conversion.py”, line 229, in convert_with_cache entity, program_ctx) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/impl/conversion.py”, line 433, in convert_entity_to_ast nodes, name, entity_info = convert_func_to_ast(o, program_ctx) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/impl/conversion.py”, line 624, in convert_func_to_ast node = node_to_graph(node, context) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/impl/conversion.py”, line 667, in node_to_graph node = converter.apply(node, context, return_statements) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/core/converter.py”, line 380, in apply_ node = converter_module.transform(node, context) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/converters/return_statements.py”, line 412, in transform node = transformer.visit(node) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/core/converter.py”, line 317, in visit return super(Base, self).visit(node) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/pyct/transformer.py”, line 480, in visit result = super(Base, self).visit(node) File “/home/username/data3/conda3/lib/python3.7/ast.py”, line 262, in visit return visitor(node) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/converters/return_statements.py”, line 363, in visit_FunctionDef converted_body = self._visit_statement_block(node, node.body) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/converters/return_statements.py”, line 287, in _visit_statement_block nodes = self.visit_block(nodes, after_visit=self._postprocess_statement) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/pyct/transformer.py”, line 371, in visit_block replacement = self.visit(node) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/core/converter.py”, line 317, in visit return super(Base, self).visit(node) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/pyct/transformer.py”, line 480, in visit result = super(Base, self).visit(node) File “/home/username/data3/conda3/lib/python3.7/ast.py”, line 262, in visit return visitor(node) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/converters/return_statements.py”, line 237, in visit_Return retval=retval) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/pyct/templates.py”, line 260, in replace replacements[k] = _convert_to_ast(replacements[k]) File “/home/username/data3/conda3/lib/python3.7/site-packages/tensorflow/python/autograph/pyct/templates.py”, line 222, in _convert_to_ast return gast.Name(id=n, ctx=None, annotation=None) File “/home/username/data3/conda3/lib/python3.7/site-packages/gast/gast.py”, line 19, in create_node format(Name, nbparam, len(Fields)) AssertionError: Bad argument number for Name: 3, expecting 4 WARNING:tensorflow:Entity <bound method EmbeddingSharedWeights.call of <model.EmbeddingSharedWeights object at 0x7fede45b6828>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, export AUTOGRAPH_VERBOSITY=10) and attach the full output. Cause: converting <bound method EmbeddingSharedWeights.call of <model.EmbeddingSharedWeights object at 0x7fede45b6828>>: AssertionError: Bad argument number for Name: 3, expecting 4

error.log Describe the expected behavior There should be no error messages. a Snippet of Code to reproduce the issue


import tensorflow as tf


class LayerNormalization(tf.layers.Layer):
    """Applies layer normalization."""

    def __init__(self, hidden_size):
        super().__init__()
        self.hidden_size = hidden_size

    def build(self, input_shape):
        with tf.variable_scope("layer_norm"):
            self.scale = tf.get_variable("layer_norm_scale", [self.hidden_size], 
              initializer=tf.ones_initializer())
            self.bias = tf.get_variable("layer_norm_bias", [self.hidden_size], 
              initializer=tf.zeros_initializer())
        self.built = True

    def call(self, x, epsilon=1e-6):
        mean = tf.reduce_mean(x, axis=[-1], keepdims=True)
        variance = tf.reduce_mean(tf.square(x - mean), axis=[-1], keepdims=True)
        norm_x = (x - mean) * tf.rsqrt(variance + epsilon)
        return norm_x * self.scale + self.bias


if __name__ == "__main__":
    x = tf.random_uniform((23, 29))
    ln = LayerNormalization(29)

    y = ln(x)

    config = tf.ConfigProto()
    config.gpu_options.allow_growth = True

    sess = tf.Session(config=config)
    sess.run(tf.global_variables_initializer())
    sess.run(y)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 17 (3 by maintainers)

Most upvoted comments

#32383 Had similar issue. Using gast 0.2.2 seems to have solved it for me

@WingsBrokenAngel Can you please confirm if @Jonathan-Oehley’s workaround is working for you by installing gast ( pip install gast==0.2.2).Thanks!

Downgrading from gast==0.3.2 to gast==0.2.2 also solved the problem for me

After installing gast 0.2.2 (which requried uninstalling gast 0.3.3):

➜ pip install "gast==0.2.2"
Processing /Users/dima/Library/Caches/pip/wheels/5c/2e/7e/a1d4d4fcebe6c381f378ce7743a3ced3699feb89bcfbdadadd/gast-0.2.2-cp37-none-any.whl
Installing collected packages: gast
  Attempting uninstall: gast
    Found existing installation: gast 0.3.3
    Uninstalling gast-0.3.3:
      Successfully uninstalled gast-0.3.3
Successfully installed gast-0.2.2

I confirm that it helped to solve the issue.

same here, downgraded gast to gast == 0.2.2 using pip install gast==0.2.2 and it resolved the issue

I confirm the warning also happen to me using TF 2.0.0. Downgrading to 0.2.2 also worked.

Confirming for TF 1.14.0, conda install gast=0.2.2 removed the warning.