2017-12-28 5 views
-1

나는 tf.estimate.quickstart의 코드를 사용하여 내 자신의 이미지 분류 작업을 실행했으며 제목에 오류가 계속 표시되어 전체 코드입니다. :TypeError : 예상 문자열, int 유형이 int 인 대신

import numpy as np 
import tensorflow as tf 
import pandas as pd 

train_x = pd.read_csv('train_set_x.csv') 
train_y = pd.read_csv('train_set_y.csv') 

test_x = pd.read_csv('test_set_x.csv') 
test_y = pd.read_csv('test_set_y.csv') 
feature_columns = [tf.feature_column.numeric_column("x", shape=[784])] 

uni = set() 
for i in range(0,26): 
str(i) 
uni.add(i) 

uni = list(uni) 


train_input_fn = tf.estimator.inputs.numpy_input_fn(
    x={"x": np.array(train_x)}, 
    y=np.array(train_y), 
    num_epochs=None, 
    shuffle=True) 
classifier = tf.estimator.DNNClassifier(feature_columns=feature_columns, 
    hidden_units=[10, 20, 10], 
    n_classes=26, 
    model_dir="/tmp/test_run", 
    label_vocabulary=uni) 


classifier.train(input_fn=train_input_fn, steps=1) 

test_input_fn = tf.estimator.inputs.numpy_input_fn(
    x={"x": np.array(test_x)}, 
    y=np.array(test_y), 
    num_epochs=1, 
    shuffle=False) 
accuracy_score = classifier.evaluate(input_fn = test_input_fn)["Accuracy"] 

print("\nTest Accuracy: {0:f}\n".format(accuracy_score)) 

내가 사용했던 데이터 세트는, 내가 .csv 파일로 변환 한 28 X 28의 크기에 손으로 쓴 편지의 이미지를 포함하는 EMNIST 데이터 세트 인이 이미지에 대해 갈 수있는 올바른 방법이다 인식 교육? 오류가있는 라인에서 발생 classifier.train(input_fn=train_input_fn, steps=1) 여기에 전체 스택 추적입니다 :

역 추적 (마지막으로 가장 최근 통화) : 파일 "C : /Users/Slither/Documents/Scripts/lol.py", 라인 (33) , 열 에있는 파일 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ estimator.py"(302 행)에서 classifier.train (input_fn = train_input_fn, steps = 1) 손실 = self._train_model (input_fn, hooks, saving_listeners) 파일 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ estimator.py", 줄 711, _train_model에 기능, 레이블 , model_fn_lib.ModeKeys.TRAIN, self.config) 파일 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ estimator.py", 줄 694, _call_model_fn에서 model_fn_results = self._model_fn (features = features, ** kwargs) 파일 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimater \ canned \ dnn.py"_model_fn config = config에서파일 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ estimator \ canned \ dnn.py "줄 203, _dnn_model_fn logits = logits) 파일"C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ ops \ lookup_ops. "파일 이름 : 'python \ estimator \ canned \ head.py"456 줄, create_estimator_spec name ='class_string_lookup ') 파일 py ", 1197 줄, index_to_string_tab le_from_tensor convert_to_tensor as_ref에있는 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ ops.py"파일의 836 줄에있는 vocabulary_list = ops.convert_to_tensor (vocabulary_list, dtypes.string) = false) internal_convert_to_tensor에서 926 행의 파일 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tenspsflow"를 입력하십시오. ret = conversion_func (value, dtype = dtype, name = _constant_tensor_conversion_function에 파일 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ constant_op.py", 줄 229 return constant (v, dtype = dtype, name = name) 파일 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ constant_op.py", 줄 208, 상수는입니다. make_tensor_proto 파일의 "C : \ Users \ Slither \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ tensor_util.py"파일, 383 줄에있는 파일, dtype = dtype, shape = 모양, verify_shape = verify_shape)) _AssertCompatible _AssertCompatible에있는 "C : \ Users \ Slither \ Anaconda3 \), (불일치)를 입력하십시오. 이름)) TypeError : 예상되는 문자열로 'int'유형이 0입니다.

프로세스 어휘는 문자열이기로되어 있지만 정수를 추가하는 종료 코드 1

+0

전체 오류 스택 추적을 제공 할 수 있습니까? – Ragu

+0

@Ragu 편집을 완료하고 전체 스택 추적을 추가했습니다. – weens

답변

0

완료 (당신은 아마 내가 = str을 (내가 의미 할 때 STR (I를 호출)하고 결과를 무시)).

관련 문제