张量流神经网络误差

时间:2017-10-18 02:39:07

标签: python tensorflow scikit-learn

我在数据集上运行神经网络算法但遇到错误。我不确定这个错误是什么意思或如何解决它。数据集很简单 1 0 1 0 1 0等等,第三列将是我正在分类的类别。我的代码如下:

81c81
<   [28] .shstrtab         STRTAB           0000000000000000  0000189f
---
>   [28] .shstrtab         STRTAB           0000000000000000  000018a0
86c86
<        0000000000000207  0000000000000000           0     0     1
---
>        0000000000000208  0000000000000000           0     0     1
211c211
<     37: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS FIRST_PROG.c
---
>     37: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS SECOND_PROG.c
258c258
<     Build ID: 2c64961288049002e34a1f14e55d6c80dd96816c
---
>     Build ID: 5425dec81aae53bd30e85fe94659d320bb774dcc

当我运行此代码时,我收到from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import urllib import tensorflow as tf import numpy as np Stock_TRAINING = "Stocks.csv" Stock_TEST = "Workbook2.csv" # Load datasets. training_set = tf.contrib.learn.datasets.base.load_csv_with_header( filename=Stock_TRAINING, target_dtype=np.int, features_dtype=np.int) test_set = tf.contrib.learn.datasets.base.load_csv_with_header( filename=Stock_TEST, target_dtype=np.int, features_dtype=np.int) # Specify that all features have real-value data feature_columns = [tf.feature_column.numeric_column("x", shape=[2])] # Build 3 layer DNN with 10, 20, 10 units respectively. classifier = tf.estimator.DNNClassifier(feature_columns=feature_columns, hidden_units=[10, 20, 10], n_classes=2, model_dir="/tmp/stocks") # Define the training inputs train_input_fn = tf.estimator.inputs.numpy_input_fn( x={"x": np.array(training_set.data)}, y=np.array(training_set.target), num_epochs=None, shuffle=True) # Train model. classifier.train(input_fn=train_input_fn, steps=2000) # Define the test inputs test_input_fn = tf.estimator.inputs.numpy_input_fn( x={"x": np.array(test_set.data)}, y=np.array(test_set.target), num_epochs=1, shuffle=False) # Evaluate accuracy. accuracy_score = classifier.evaluate(input_fn=test_input_fn)["accuracy"] print("\nTest Accuracy: {0:f}\n".format(accuracy_score)) # Classify two new stock samples. new_samples = np.array( [[1, 0], [1,1] [0,0], [0,1], [1, 1]], dtype=np.float32) predict_input_fn = tf.estimator.inputs.numpy_input_fn( x={"x": new_samples}, num_epochs=1, shuffle=False) predictions = list(classifier.predict(input_fn=predict_input_fn)) predicted_classes = [p["UpDown"] for p in predictions] print("Stock is Up or Down Next Day: {}\n" .format(predicted_classes))

中发生的以下错误
classifier.train(input_fn=train_input_fn, steps=2000)

如果您需要查看完整的错误消息或需要其他任何内容,请与我们联系。

0 个答案:

没有答案