我正在处理TensorFlow tutorial,它使用一种“怪异”的格式来上传数据。我想对数据使用NumPy或pandas格式,以便将其与scikit学习结果进行比较。
这里是TensorFlow教程(工作正常)中的代码:# Stuff from tensorflow tutorial
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.placeholder("float", shape=[None, 784])
y_ = tf.placeholder("float", shape=[None, 10])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
y = tf.nn.softmax(tf.matmul(x, W) + b)
cross_entropy = -tf.reduce_sum(y_ * tf.log(y))
train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)
在这里,我读取数据,去掉目标变量,并将数据分成测试和训练数据集(这一切都很好):# Read dataframe from training data
csvfile='train.csv'
from pandas import DataFrame, read_csv
df = read_csv(csvfile)
# Strip off the targe