PML-UCF / pinn

Physics-informed neural networks package
MIT License
270 stars 48 forks source link

InaccessibleTensorError: The tensor 'Tensor("table_interpolation_1/ReadVariableOp_1:0", shape=(2, 2), dtype=float32)' cannot be accessed here: it is defined in another function or code block. Use return values, explicit Python locals or TensorFlow collections to access it. Defined in: FuncGraph(name=table_interpolation_1_scratch_graph, id=2160295554184); accessed from: FuncGraph(name=predict_function, id=2159676937352). #7

Open chzhffpt704 opened 3 years ago

chzhffpt704 commented 3 years ago

I'm trying to use model.predict run in pinn/samples/run01_table_interpolation_sample.py, but I get this error.

result = model.predict(query_points) 2021-05-25 11:42:42.749901: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization WARNING:tensorflow:From C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\ops\array_ops.py:5043: calling gather (from tensorflow.python.ops.array_ops) with validate_indices is deprecated and will be removed in a future version. Instructions for updating: The validate_indices argument has no effect. Indices are always validated on CPU and never validated on GPU. Traceback (most recent call last): File "", line 1, in File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1727, in predict tmp_batch_outputs = self.predict_function(iterator) File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 889, in call result = self._call(*args, kwds) File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 933, in _call self._initialize(args, kwds, add_initializers_to=initializers) File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 763, in _initialize self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\eager\function.py", line 3050, in _get_concrete_function_internal_garbage_collected graphfunction, = self._maybe_define_function(args, kwargs) File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\eager\function.py", line 3444, in _maybe_define_function graph_function = self._create_graph_function(args, kwargs) File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\eager\function.py", line 3279, in _create_graph_function func_graph_module.func_graph_from_py_func( File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\framework\func_graph.py", line 999, in func_graph_from_py_func func_outputs = python_func(*func_args, *func_kwargs) File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\eager\def_function.py", line 672, in wrapped_fn out = weak_wrapped_fn().wrapped(args, kwds) File "C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\framework\func_graph.py", line 986, in wrapper raise e.ag_error_metadata.to_exception(e) tensorflow.python.framework.errors_impl.InaccessibleTensorError: in user code: C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\keras\engine\training.py:1569 predict_function return step_function(self, iterator) C:\Users\chosun\Desktop\work\Python\pinn\pinn\layers\core.py:140 call queryPoints_ind = ((cast(shape(self.grid)[1:3], dtype=self.dtype))-constant(1.0))(inputs-self.bounds[0])/(self.bounds[1]-self.bounds[0]) C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\util\dispatch.py:206 wrapper return target(args, *kwargs) C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\ops\array_ops.py:1040 _slice_helper return strided_slice( C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\util\dispatch.py:206 wrapper return target(args, **kwargs) C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\ops\array_ops.py:1213 strided_slice op = gen_array_ops.strided_slice( C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\ops\gen_array_ops.py:10531 stridedslice , _, _op, _outputs = _op_def_library._apply_op_helper( C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\framework\op_def_library.py:748 _apply_op_helper op = g._create_op_internal(op_type_name, inputs, dtypes=None, C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\framework\func_graph.py:597 _create_op_internal inp = self.capture(inp) C:\Users\chosun\Desktop\work\Python\pinn\venv\lib\site-packages\tensorflow\python\framework\func_graph.py:642 capture raise errors.InaccessibleTensorError( InaccessibleTensorError: The tensor 'Tensor("table_interpolation/ReadVariableOp_1:0", shape=(2, 2), dtype=float32)' cannot be accessed here: it is defined in another function or code block. Use return values, explicit Python locals or TensorFlow collections to access it. Defined in: FuncGraph(name=table_interpolation_scratch_graph, id=2178778109024); accessed from: FuncGraph(name=predict_function, id=2178777414144). Please help me

renatogn commented 3 years ago

@chzhffpt704 Can you please provide the Tensorflow version you are running?

chzhffpt704 commented 3 years ago

@renatogn I am sorry for being late I running 2.5.0 version and I installed package

absl-py 0.12.0 argon2-cffi 20.1.0 astunparse 1.6.3 async-generator 1.10 attrs 21.2.0 backcall 0.2.0 bleach 3.3.0 cached-property 1.5.2 cachetools 4.2.2 certifi 2020.12.5 cffi 1.14.5 chardet 4.0.0 colorama 0.4.4 decorator 5.0.9 defusedxml 0.7.1 entrypoints 0.3 flatbuffers 1.12 gast 0.4.0 google-auth 1.30.0 google-auth-oauthlib 0.4.4 google-pasta 0.2.0 grpcio 1.34.1 h5py 3.1.0 idna 2.10 importlib-metadata 4.0.1 ipykernel 5.5.5 ipython 7.23.1 ipython-genutils 0.2.0 ipywidgets 7.6.3 jedi 0.18.0 Jinja2 3.0.1 jsonschema 3.2.0 jupyter 1.0.0 jupyter-client 6.1.12 jupyter-console 6.4.0 jupyter-core 4.7.1 jupyterlab-pygments 0.1.2 jupyterlab-widgets 1.0.0 keras-nightly 2.5.0.dev2021032900 Keras-Preprocessing 1.1.2 Markdown 3.3.4 MarkupSafe 2.0.1 matplotlib-inline 0.1.2 mistune 0.8.4 nbclient 0.5.3 nbconvert 6.0.7 nbformat 5.1.3 nest-asyncio 1.5.1 notebook 6.4.0 numpy 1.19.5 oauthlib 3.1.0 opt-einsum 3.3.0 packaging 20.9 pandas 1.2.4 pandocfilters 1.4.3 parso 0.8.2 pickleshare 0.7.5 pinn 0.2.0 pip 21.1.1 pml-pinn 0.0.3 c:\users\chosun\desktop\work\python\pinn prometheus-client 0.10.1 prompt-toolkit 3.0.18 protobuf 3.17.0 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycparser 2.20 Pygments 2.9.0 PyJWT 2.1.0 pyparsing 2.4.7 pyrsistent 0.17.3 python-dateutil 2.8.1 pytz 2021.1 pywin32 300 pywinpty 1.1.1 pyzmq 22.0.3 qtconsole 5.1.0 QtPy 1.9.0 requests 2.25.1 requests-oauthlib 1.3.0 rsa 4.7.2 Send2Trash 1.5.0 setuptools 52.0.0.post20210125 six 1.15.0 tb-nightly 2.6.0a20210522 tensorboard 2.5.0 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.0 tensorflow 2.5.0 tensorflow-estimator 2.5.0 termcolor 1.1.0 terminado 0.10.0 testpath 0.5.0 tf-estimator-nightly 2.5.0.dev2021032601 tf-nightly 2.6.0.dev20210523 tornado 6.1 traitlets 5.0.5 typing-extensions 3.7.4.3 urllib3 1.26.4 wcwidth 0.2.5 webencodings 0.5.1 Werkzeug 2.0.1 wheel 0.36.2 widgetsnbextension 3.5.1 wincertstore 0.2 wrapt 1.12.1 zipp 3.4.1

thanks!