Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Python Tensorflow:UnimplementedError: Cast string to int32 is not supported

Helena Yang:

everyone. I am new to Tensorflow When I wrote the code like this in this part :


def get_batch(image,label,new_height,new_width,batch_size,capacity):
image=tf.cast(image,tf.string)
label=tf.cast(image,tf.int32)

input_queue= tf.train.slice_input_producer([image,label])
label=input_queue[1]
image_contents=tf.read_file(input_queue[0])
image=tf.image.decode_jpeg(image_contents,channels=3)

image=tf.image.resize_images(image,(new_height,new_width))
image=tf.image.per_image_standardization(image)
image_batch,label_batch=tf.train.batch([image,label],batch_size=batch_size,capacity=capacity,num_threads=8)

label_batch=tf.reshape(label_batch,[batch_size])
return image_batch,label_batch

Btw. the Args: images ,labels are returned from another function, which read the files that store images and labels.And I define the new_height and new_width as constant when I run this code


I met the error like this:

UnimplementedError (see above for traceback): Cast string to int32 is not supported
[[Node: Cast_1 = Cast[DstT=DT_INT32, SrcT=DT_STRING, _device="/job:localhost/replica:0/task:0/cpu:0"](Cast/x)]]

Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/yanghang/ugthesis/mean subtraction.py', wdir='C:/Users/yanghang/ugthesis')

File "C:\Users\yanghang\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
execfile(filename, namespace)

File "C:\Users\yanghang\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/yanghang/ugthesis/mean subtraction.py", line 102, in
coord.join(threads)

File "C:\Users\yanghang\Anaconda3\lib\site-packages\tensorflow\python\training\coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)

File "C:\Users\yanghang\Anaconda3\lib\site-packages\six.py", line 686, in reraise
raise value

File "C:\Users\yanghang\Anaconda3\lib\site-packages\tensorflow\python\training\queue_runner_impl.py", line 234, in _run
sess.run(enqueue_op)

File "C:\Users\yanghang\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 778, in run
run_metadata_ptr)

File "C:\Users\yanghang\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 982, in _run
feed_dict_string, options, run_metadata)

File "C:\Users\yanghang\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1032, in _do_run
target_list, options, run_metadata)

File "C:\Users\yanghang\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)`

Could u tell me how to solve this problem? Thanks in advance



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Python Tensorflow:UnimplementedError: Cast string to int32 is not supported

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×