2016-10-20 2 views
4

다른 이미지 디코더를 호출하기 위해 이미지 파일의 확장자를 가져오고 싶습니다. tensorflow r0.11에 tf.string_split라는 함수가 있습니다.tensorflow에서 tf.string_split()을 어떻게 사용할 수 있습니까?

ValueError: Shape must be rank 1 but is rank 0 for 'StringSplit' (op: 'StringSplit') with input shapes: [], []. 

내가이 img_src의 형상 추론에 의한 것 같아요 : 나는 그것을 실행할 때

filename_queue = tf.train.string_input_producer(filenames, shuffle=shuffle) 
reader = tf.WholeFileReader() 
img_src, img_bytes = reader.read(filename_queue) 
split_result = tf.string_split(img_src, '.') 

는하지만,이 오류가 발생합니다. 또한

ValueError: Shapes() and (1,) are not compatible 

, 나는 결과는 img_src shape=[]입니다

tf.Print(split_result, [tf.shape(img_src)],'img_src shape=') 

사용 img_src의 모양을 얻을 수 없습니다 :이 오류가 발생, 나는 그것을 해결하기 위해 img_src.set_shape([1,])을 사용하려고하지만, 작동하지 않을 것 같다 . 나는 다음과 같은 코드를 사용한다면 :

tf.Print(split_result, [img_src],'img_src=') 

결과는 img_src=test_img/test1.png입니다. 내가 뭔가 잘못하고 있는거야?

+0

'img_src'을 (를) 꾸리십시오. 'split_result = tf.string_split ([img_src], '.')'을 시도해보고 작동하는지 알려주세요. – nessuno

+0

작동합니다! 정말 고마워!!! –

+0

반갑습니다. 나는 당신이 그것을 받아 들일 수 있도록 대답을 주석으로 옮깁니다. – nessuno

답변

5

텐서에 img_src을 그냥 포장하십시오.

split_result = tf.string_split([img_src], '.') 
관련 문제