TensorFlow Debugging FAQs (Pycharm)

Source: Internet
Author: User
Tags in python
1. runtimeerror:attempted to use a closed Session.

The following issues occur when the pycharm is lowered with the TensorFlow library:

Runtimeerror:attempted to use a closed Session.

Workaround: Move the program starting with step=5000 to the right, contained within "with"

Possible problems: Python code to move the entire selection of code, press the "tab" key to move the entire selection of code, press the "Shift+tab" key to move the whole left 2. Attributeerror:module ' TensorFlow ' has no attribute ' select '

Error calling Tf.select

Replace Tf.select with Tf.where to 3. Unicodedecodeerror: ' Utf-8 ' codec can ' t decode byte 0xff in position 0:invalid start byte

The above error occurs when reading an image using TensorFlow's tf.gfile.FastGFile:

Original code:

Image_raw_data=tf.gfile.fastgfile (' anglababy.jpg ', ' R '). Read ()

change ' r ' to ' RB '
4. After displaying the image with Plt.imshow () in Python, the program stops running and the displayed image must be turned off to continue running

You can write show () in the process, by invoking the process to open the picture, then the running state of the process will not affect the main program down the execution of the ===============================

Import threading
Import Image
Class ThreadClass (threading. Thread):
def run (self):
Im=image.open (' z.jpg ')
Im.show ()

Print (1)
t = ThreadClass ()
T.start ()
Print (2)
A=input (' End ') ===============================

The result is: Print out ' 1 ' first, then display the picture z.jpg, then print out ' 2 ' without closing the picture.
You can organize your code as needed when you use it. 5. Attributeerror:module ' Tensorflow.python.ops.image_ops ' has no attribute ' per_image_whitening '

TensorFlow modified the normalization function tf.image.per_image_whitening (Img_data) into the following form:

Adjusted = tf.image.per_image_standardization (img_data)

6. Valueerror:tried to convert ' min_object_covered ' to a tensor and failed. Error:none values not supported.

Workaround:

Begin, size, Bbox_for_draw = Tf.image.sample_distorted_bounding_box (
        tf.shape (img_data), bounding_boxes=boxes, min_object_covered=0.1)
7. Nameerror:name ' Xrange ' is not defined

workaround: In Python 3, range () is merged with Xrange () to range ()

8. Tensorflow.python.framework.errors_impl. Failedpreconditionerror:attempting to use uninitialized value Matching_filenames

TensorFlow actual combat Google Deep Learning Framework, input file queue program error

The reason is: Tf.global_variables_initializer (). Run ()

To change to: Sess.run ([Tf.global_variables_initializer (), Tf.local_variables_initializer ()])

Tf.local_variables_initializer (): Returns an operation (OP) that initializes all local variables. If you put the graph into a session, you will be able to initialize all local variables by running this operation, essentially equivalent to Variable_initializers (Local_variables ())

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.