gpt4 book ai didi

python - 将稀疏数据输入到 Tensorflow Estimator 中进行拟合

转载 作者:太空宇宙 更新时间:2023-11-03 14:22:14 27 4
gpt4 key购买 nike

我将标签转换为稀疏的稀疏标签元组(索引、值、形状)。但是,当我将其输入分类器时,我遇到了以下错误:

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'

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

最佳答案

错误消息非常清楚地表明“tuple”没有“dtype”属性。您可能想将标签转换为 numpy 数组(仅包含值)?

关于python - 将稀疏数据输入到 Tensorflow Estimator 中进行拟合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47863220/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com