python数据类型的操作(Operations on python datatypes)

编程入门 行业动态 更新时间:2024-10-25 04:19:57
python数据类型的操作(Operations on python datatypes)

我是python和tensorflow的新手。 如何检查变量可以执行哪些操作? 我试图将图像存储到列表中。 我想知道它的大小只是为了确认。

这是从网站上获取的代码。

# Typical setup to include TensorFlow. import tensorflow as tf # Make a queue of file names including all the JPEG images files in the relative # image directory. filename_queue = tf.train.string_input_producer( tf.train.match_filenames_once("./images/*.jpg")) # Read an entire image file which is required since they're JPEGs, if the images # are too large they could be split in advance to smaller files or use the Fixed # reader to split up the file. image_reader = tf.WholeFileReader() print(len(filename_queue))

我在下面收到了一个错误。 这是函数string_input_producer的网站https://www.tensorflow.org/api_docs/python/io_ops/input_pipeline#string_input_producer它确实说它返回一个列表所以我不知道我做错了什么

Traceback (most recent call last): File "tf_load_jpg.py", line 14, in <module> print(len(filename_queue)) TypeError: object of type 'FIFOQueue' has no len()

Im new to python and tensorflow. How can I check what operations can be done on a variable ? Im trying to store images into a list. Id like to find out its size just to confirm.

This is the code taken from the website.

# Typical setup to include TensorFlow. import tensorflow as tf # Make a queue of file names including all the JPEG images files in the relative # image directory. filename_queue = tf.train.string_input_producer( tf.train.match_filenames_once("./images/*.jpg")) # Read an entire image file which is required since they're JPEGs, if the images # are too large they could be split in advance to smaller files or use the Fixed # reader to split up the file. image_reader = tf.WholeFileReader() print(len(filename_queue))

I got an error below. This is the website for the function string_input_producer https://www.tensorflow.org/api_docs/python/io_ops/input_pipeline#string_input_producer it does say it returns a list so im not sure what im doing wrong

Traceback (most recent call last): File "tf_load_jpg.py", line 14, in <module> print(len(filename_queue)) TypeError: object of type 'FIFOQueue' has no len()

最满意答案

如评论中所述,您应该使用dir(filename_queue)来检查对象中的函数集。 这输出以下 -

['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_check_enqueue_dtypes', '_dequeue_return_value', '_dtypes', '_name', '_names', '_queue_ref', '_scope_vals', '_shapes', 'close', 'dequeue', 'dequeue_many', 'dequeue_up_to', 'dtypes', 'enqueue', 'enqueue_many', 'from_list', 'name', 'names', 'queue_ref', 'shapes', 'size']

使用size()函数来获得结果。 您可以阅读有关FIFOQueue更多信息。

As mentioned in the comments, you should use dir(filename_queue) to check the set of functions in an object. This outputs the following -

['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_check_enqueue_dtypes', '_dequeue_return_value', '_dtypes', '_name', '_names', '_queue_ref', '_scope_vals', '_shapes', 'close', 'dequeue', 'dequeue_many', 'dequeue_up_to', 'dtypes', 'enqueue', 'enqueue_many', 'from_list', 'name', 'names', 'queue_ref', 'shapes', 'size']

Make use of the size() function to get your result. You can read more about FIFOQueue.

更多推荐

本文发布于:2023-08-05 07:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428791.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据类型   操作   python   Operations   datatypes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!