Skip to content
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

some error with scope #2

Open
Bitsy-Chuck opened this issue Aug 1, 2020 · 4 comments
Open

some error with scope #2

Bitsy-Chuck opened this issue Aug 1, 2020 · 4 comments

Comments

@Bitsy-Chuck
Copy link

 TypeError: An op outside of the function building code is being passed
    a "Graph" tensor. It is possible to have Graph tensors
    leak out of the function building context by including a
    tf.init_scope in your function building code.
    For example, the following function will fail:
      @tf.function
      def has_init_scope():
        my_constant = tf.constant(1.)
        with tf.init_scope():
          added = my_constant * 2
    The graph tensor has name: model/pconv2d_enc_1/Shape:0

Getting this error while trying to train the code using CLI.
The complete traceback is as follows. Any help is super appreciated

2020-08-02 04:01:27.519864: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2020-08-02 04:01:27.541115: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2599990000 Hz
2020-08-02 04:01:27.541850: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5578c71a0d30 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-08-02 04:01:27.541891: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-08-02 04:01:27.541986: I tensorflow/core/common_runtime/process_util.cc:147] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
2020-08-02 04:01:28.536401: I tensorflow/core/profiler/lib/profiler_session.cc:159] Profiler session started.
WARNING:tensorflow:From inpainter_main.py:47: Model.fit_generator (from tensorflow.python.keras.engine.training) is deprecated and will be removed in a future version.
Instructions for updating:
Please use Model.fit, which supports generators.
Traceback (most recent call last):
  File "inpainter_main.py", line 47, in <module>
    model.fit_generator(
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/util/deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 1465, in fit_generator
    return self.fit(
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 66, in _method_wrapper
    return method(self, *args, **kwargs)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 848, in fit
    tmp_logs = train_function(iterator)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 580, in __call__
    result = self._call(*args, **kwds)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 627, in _call
    self._initialize(args, kwds, add_initializers_to=initializers)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 505, in _initialize
    self._stateful_fn._get_concrete_function_internal_garbage_collected(  # pylint: disable=protected-access
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 2446, in _get_concrete_function_internal_garbage_collected
    graph_function, _, _ = self._maybe_define_function(args, kwargs)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 2777, in _maybe_define_function
    graph_function = self._create_graph_function(args, kwargs)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 2657, in _create_graph_function
    func_graph_module.func_graph_from_py_func(
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 981, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 441, in wrapped_fn
    return weak_wrapped_fn().__wrapped__(*args, **kwds)
  File "/home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py", line 968, in wrapper
    raise e.ag_error_metadata.to_exception(e)
TypeError: in user code:

    /home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:571 train_function  *
        outputs = self.distribute_strategy.run(
    /home/bitsy-chuck/Downloads/PConv2D-2ndimp/inpainter_utils/pconv2d_layer.py:71 call  *
        sum_1 = sum_1i * K.ones(K.shape(sum_m))
    /home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/backend.py:1365 ones  **
        v = array_ops.ones(shape=shape, dtype=tf_dtype, name=name)
    /home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/ops/array_ops.py:2979 ones
        output = fill(shape, constant(one, dtype=dtype), name=name)
    /home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/ops/array_ops.py:234 fill
        result = gen_array_ops.fill(dims, value, name=name)
    /home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/ops/gen_array_ops.py:3311 fill
        return fill_eager_fallback(
    /home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/ops/gen_array_ops.py:3338 fill_eager_fallback
        _result = _execute.execute(b"Fill", 1, inputs=_inputs_flat, attrs=_attrs,
    /home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/execute.py:75 quick_execute
        raise e
    /home/bitsy-chuck/anaconda3/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/eager/execute.py:59 quick_execute
        tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,

    TypeError: An op outside of the function building code is being passed
    a "Graph" tensor. It is possible to have Graph tensors
    leak out of the function building context by including a
    tf.init_scope in your function building code.
    For example, the following function will fail:
      @tf.function
      def has_init_scope():
        my_constant = tf.constant(1.)
        with tf.init_scope():
          added = my_constant * 2
    The graph tensor has name: model/pconv2d_enc_1/Shape:0

@Bitsy-Chuck
Copy link
Author

@ezavarygin

@ezavarygin
Copy link
Owner

Hi @Bitsy-Chuck,

What versions of Tensorflow and Keras do you use?

@Bitsy-Chuck
Copy link
Author

tf 1.3
keras 2.2.4

@ezavarygin
Copy link
Owner

I used 1.13. I suggest downgrading TF to 1.13 and see if the problem remains.

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

No branches or pull requests

2 participants