TypeError:传递给参数'input'的值的数据类型float64不在允许的值列表中:float16,bfloat16,float32 [英] TypeError: Value passed to parameter 'input' has DataType float64 not in list of allowed values: float16, bfloat16, float32
问题描述
我已经阅读了许多与我的问题类似的问题,但所有问题都与我的不同。
用于xrange中的itr(MAX_ITERATION):
train_images,train_annotations = train_dataset_reader.next_batch(batch_size)
#train_images = tf.image.convert_image_dtype(train_images,np.float32)
#train_annotations = tf.image.convert_image_dtype(train_annotations,np.float32)
#print(train_images_.get_shape() ,train_annotations_.get_shape())
#train_images = tf.cast(train_images,tf.float32)
#train_images = tf.to_float(train_images)
#train_annotations = tf.to_float(train_annotations)
#train_images,train_annotations = py_func(selftrans,[train_images_,train_annotations_],[tf.float32],grad = None)
print(train_images.dtype)
#train_annotations = tf.cast( train_annotations,tf.float32)
#train_images,train_annotations = sess.run([train_images,train_annotations])
#train_images = t rain_images.astype('float32')
#train_annotations = train_annotations.astype('float32')
#print(train_annotations.dtype)
feed_dict = {image:train_images,注解:train_annotations,keep_probability :1}
sess.run(train_op,feed_dict = feed_dict)
问题是:使用我自己的数据(容器分割,这是两个分类问题)后,使用next_batch读取的数据为float64,而 feed_dict()
需要float32 。通常,诸如 tf.cast或tf.tp_float
之类的代码可用于将我的数据转换为float32。但是,在使用这些转换代码之后,我发现错误更改为 TypeError:供稿的值不能为tf.Tensor对象。可接受的feed值包括Python标量,字符串,列表,numpy ndarrays或TensorHandles。
最后,我尝试使用sess.run来抵消其tf.Tensor形式。 Erorr更改为原始版本,这意味着我的数据已转换回float64。
因此,这似乎是一个无休止的循环。未经转换,将不接受float64。转换后,Tf也将不被接受。张量Tensor可以抵消。使用sess运行Tensor表单,数据将同时转换回float64。如何解决此问题?我期待您的回复!类似的问题在这里, TensorFlow TypeError:传递给参数输入的值的DataType uint8不在允许值列表中:float16,float32
我认为这是由我的配置环境引起的。按照说明安装环境后(在此处输入链接描述),代码变得可行。 / p>
I have read many questions similar to mine, but all of them are different with mine.
for itr in xrange(MAX_ITERATION):
train_images, train_annotations = train_dataset_reader.next_batch(batch_size)
# train_images=tf.image.convert_image_dtype(train_images,np.float32)
# train_annotations=tf.image.convert_image_dtype(train_annotations,np.float32)
# print(train_images_.get_shape(),train_annotations_.get_shape())
# train_images=tf.cast(train_images,tf.float32)
# train_images = tf.to_float(train_images)
# train_annotations = tf.to_float(train_annotations)
#train_images, train_annotations = py_func(selftrans, [train_images_, train_annotations_], [tf.float32], grad=None)
print(train_images.dtype)
# train_annotations=tf.cast(train_annotations,tf.float32)
# train_images,train_annotations = sess.run([train_images,train_annotations])
# train_images = train_images.astype('float32')
# train_annotations = train_annotations.astype('float32')
# print(train_annotations.dtype)
feed_dict = {image: train_images, annotation: train_annotations, keep_probability: 1}
sess.run(train_op, feed_dict=feed_dict)
The question is: After I use my own data (vessel segmentation, which is a Two Classification Problems), the data read by using next_batch is float64, while feed_dict()
needs float32. Commonly, codes like tf.cast or tf.tp_float
can be used to convert my data to float32. However, after using those converting codes, I found the error changed to TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, numpy ndarrays, or TensorHandles.
Finally, I tried to use sess.run to off-set its tf.Tensor form. Erorr changed to the original one, which means my data was converted back to float64.
Thus, it seems to be an endless loop. "Without converting, float64 will not be accepted. After converting, Tf. Tensor will also not be accepted. To off-set the tf.Tensor form using sess run, data will be converted back to float64 simultaneously" How can I fix this? I am looking forward to your reply !The similar question is here, TensorFlow TypeError: Value passed to parameter input has DataType uint8 not in list of allowed values: float16, float32
I think this is caused by my configuration environment. Once I installed my environment as told (enter link description here), the code becomes feasible.
这篇关于TypeError:传递给参数'input'的值的数据类型float64不在允许的值列表中:float16,bfloat16,float32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!