I converted a label into sparse a sparse label tuple (indices, values, shape). However, when I feed it to the classifier, I encounter this error:
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'
How do I feed a sparse tuple into the classifier?
答案 0 :(得分:1)
错误信息非常明确表示&#39; tuple&#39;没有&#39; dtype&#39;的属性。您可能希望将标签转换为numpy数组(仅包含值)?