runpuchen / DeepType

20 stars 8 forks source link

Code run problem #3

Open GEHAH opened 4 years ago

GEHAH commented 4 years ago

Show the following questions:

tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable Variable from Container: localhost. This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/Variable) [[node weights1/Initializer/ReadVariableOp (defined at D:\pycharm_act\DeepType\model.py:120) ]]

Errors may have originated from an input operation. Input Source operations connected to node weights1/Initializer/ReadVariableOp: Variable (defined at D:\pycharm_act\DeepType\model.py:117)

abhay8154 commented 3 years ago

Show the following questions:

tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable Variable from Container: localhost. This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/Variable) [[node weights1/Initializer/ReadVariableOp (defined at D:\pycharm_act\DeepType\model.py:120) ]]

Errors may have originated from an input operation. Input Source operations connected to node weights1/Initializer/ReadVariableOp: Variable (defined at D:\pycharm_act\DeepType\model.py:117)

Use

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

in place of import tensorflow as tf

This replacement will work out just fine.

The reason is that the code scripts are compatible with TensorFlow version <2.0

Read this

Eager execution TensorFlow 1.X requires users to manually stitch together an abstract syntax tree (the graph) by making tf.* API calls. It then requires users to manually compile the abstract syntax tree by passing a set of output tensors and input tensors to a session.run() call. TensorFlow 2.0 executes eagerly (like Python normally does) and in 2.0, graphs and sessions should feel like implementation details.

Reference: https://www.tensorflow.org/guide/effective_tf2