目前,我正在研究DNNC分类器,以预测第二天的库存趋势。
以下是使用tensorflow创建的DNNClassifier的代码:
feature_columns = [tf.contrib.layers.real_valued_column(k) for k in FEATURES]
classifier = tf.contrib.learn.DNNClassifier(feature_columns=feature_columns,
hidden_units=[250, 200, 150, 100, 50],
n_classes=5,
model_dir="/stock_model")
def input_fn(data_set):
feature_cols = {k: tf.constant(data_set[k].values) for k in FEATURES}
labels = tf.constant(data_set[LABEL].values)
#print (feature_cols)
return feature_cols, labels
estimator = tf.contrib.learn.Estimator(model_fn=classifier)
estimator.fit(input_fn=lambda:input_fn(training_set), steps=5000)
执行时代码抛出以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/phani/anaconda3/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "/home/phani/anaconda3/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/phani/TensorFlow/pythoncodefordnnclassifier/iris_Classification.py", line 45, in <module>
estimator = tf.contrib.learn.Estimator(model_fn=classifier)
File "/home/phani/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 990, in __init__
if params is None or 'params' in model_fn_args:
TypeError: argument of type 'NoneType' is not iterable
你能帮我解决一下吗?如果这是一个现有问题,那么链接就会有很大帮助。
感谢。