【问题标题】:Feeding a Sparse Data into Tensorflow Estimator's Fit将稀疏数据输入到 TensorFlow Estimator 的拟合中
【发布时间】:2017-12-18 06:32:55
【问题描述】:

我将一个标签转换为一个稀疏标签元组(索引、值、形状)。但是,当我将它提供给分类器时,我遇到了这个错误:

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'

如何将稀疏元组输入分类器?

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    错误消息很清楚地说'tuple'没有'dtype'的属性。您可能希望将标签转换为 numpy 数组(仅包含值)?

    【讨论】:

    • 我将密集标签输入拟合函数而不是稀疏标签,并在模型函数中进行转换。但是,我现在面临这个问题中讨论的这个错误:stackoverflow.com/questions/48201725/…
    猜你喜欢
    • 2019-04-11
    • 2018-03-16
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    • 1970-01-01
    • 2020-03-14
    • 1970-01-01
    • 2016-09-18
    相关资源
    最近更新 更多