简体   繁体   English

ValueError:tensorflow中以10为底的int()的无效文字

[英]ValueError: invalid literal for int() with base 10 in tensorflow

i am trying to play with image in tensorflow and i am trying to run this code but its giving this error : 我正在尝试在tensorflow中使用图像,并且我正在尝试运行此代码,但它给出了此错误:

/anaconda/bin/python "/Users/tony/Downloads/Tensorflow learning/9th pro.py"
/anaconda/lib/python3.5/site-packages/matplotlib/tight_layout.py:222: UserWarning: tight_layout : falling back to Agg renderer
  warnings.warn("tight_layout : falling back to Agg renderer")
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Traceback (most recent call last):
  File "/Users/tony/Downloads/Tensorflow learning/9th pro.py", line 11, in <module>
    sess_1=sess.run(slice_thing,feed_dict={place_holder1:image_a})
  File "/anaconda/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 767, in run
    run_metadata_ptr)
  File "/anaconda/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 938, in _run
    np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
  File "/anaconda/lib/python3.5/site-packages/numpy/core/numeric.py", line 531, in asarray
    return array(a, dtype, copy=False, order=order)
ValueError: invalid literal for int() with base 10: 'dd.jpg'

my code is : 我的代码是:

import skimage.io as i
import matplotlib.pyplot as plt
import tensorflow as tf

image_a="dd.jpg"
read_image=i.imread(image_a)
show_image=i.imshow(image_a)
place_holder1=tf.placeholder("uint8",[None,None,3])
slice_thing=tf.slice(place_holder1,[1,1,0],[1,1,0])
with tf.Session() as sess:
    sess_1=sess.run(slice_thing,feed_dict={place_holder1:image_a})
    print(sess_1.shape)
print(i.imshow(sess_1))
plt.show()

if i am trying to replace int with float : 如果我想用float替换int:

place_holder1=tf.placeholder("float32",[None,None,3])

then i am getting this error : 然后我得到这个错误:

ValueError: could not convert string to float: 'dd.jpg'

my second question is what is 3 in this line 我的第二个问题是这行是3

place_holder1=tf.placeholder("unit8",[None,None,3])

if i learned correctly then None , None = row , col 如果我学习正确,则None,None = row,col

placeholder("unit8",[row,col,3] 

i understand its a Matrix of unconstrained size 我了解它的大小不受限制的矩阵

but what is the 3 here ?? 但是这里的3是什么?

Your place_holder1 is a tensor of size None, None, 3 and type float ( tf.placeholder("float32",[None,None,3]) ). 您的place_holder1是一个张量,大小为None,None,3,类型为float( tf.placeholder("float32",[None,None,3]) )。 Instead of it you pass a string which is a name of the file. 取而代之的是传递一个字符串,它是文件名。 Read this file and convert it to a tensor. 读取此文件并将其转换为张量。

Your 3 is the number of channels (colors). 您的3是通道数(颜色)。 For RGB images it is 3. 对于RGB图像为3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM