2017-12-18 122 views
1

我轉換標籤成稀疏的稀疏標籤元組(索引,值,形狀)。但是,當我將它饋送給分類器時,我遇到此錯誤:餵養稀疏數據到Tensorflow估計的擬合

Traceback (most recent call last): 
    File ..., line 23, in <module> 
    classifier.fit(x=x_train, y=sparse_y_train, batch_size=128, steps=10) 
    File "...tensorflow\python\util\deprecation.py", line 316, in new_func 
    return func(*args, **kwargs) 
    File "...tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 464, in fit 
    SKCompat(self).fit(x, y, batch_size, steps, max_steps, monitors) 
    File "...tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1429, in fit 
    epochs=None) 
    File "...tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 139, in _get_input_fn 
    epochs=epochs) 
    File "...tensorflow\contrib\learn\python\learn\learn_io\data_feeder.py", line 151, in setup_train_data_feeder 
    x, y, n_classes, batch_size, shuffle=shuffle, epochs=epochs) 
    File "...tensorflow\contrib\learn\python\learn\learn_io\data_feeder.py", line 326, in __init__ 
    if y_is_dict else check_array(y, y.dtype)) 
AttributeError: 'tuple' object has no attribute 'dtype' 

如何向分類器中提供稀疏元組?

回答

1

的錯誤信息是很清楚的寫着「元組」沒有「D型」的屬性。你可能想將你的標籤轉換爲一個numpy數組(只有值)?

+0

我餵了密集的標籤進入到裝配功能,而不是那些稀疏並做了model_function內的轉換。不過,我在面對現在這個問題討論了這個錯誤: https://stackoverflow.com/questions/48201725/converting-tensor-to-a-sparsetensor-for-ctc-loss?noredirect=1#comment83393474_48201725 –