TypeError: Value passed to parameter 'input' has DataType float64 not in list of allowed values: float16, bfloat16, float32

我的梦境 提交于 2019-12-11 03:38:17

问题


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


回答1:


I think this is caused by my configuration environment. Once I installed my environment as told (enter link description here), the code becomes feasible.



来源:https://stackoverflow.com/questions/49419720/typeerror-value-passed-to-parameter-input-has-datatype-float64-not-in-list-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!