它主要是网站上教程的复制粘贴.我收到一个错误:
无效的参数:ConcatOp:预期串接在范围[0的尺寸,0),但得到0 [[节点:CONCAT =的毗连[N = 4,T = DT_INT32,_device ="/作业:本地主机/复制:0 /任务: 0/cpu:0"](concat/concat_dim,DecodeCSV,DecodeCSV:1,DecodeCSV:2,DecodeCSV:3)]]
我的csv文件的内容是:
3,4,1,8,4
import tensorflow as tf
filename_queue = tf.train.string_input_producer(["test2.csv"])
reader = tf.TextLineReader()
key, value = reader.read(filename_queue)
# Default values, in case of empty columns. Also specifies the type of the
# decoded result.
record_defaults = [[1], [1], [1], [1], [1]]
col1, col2, col3, col4, col5 = tf.decode_csv(
value, record_defaults=record_defaults)
# print tf.shape(col1)
features = tf.concat(0, [col1, col2, col3, col4])
with tf.Session() as sess:
# Start populating the filename queue. …
Run Code Online (Sandbox Code Playgroud) 我想制作一个简单的神经网络,它应该只实现XOR门.我在python中使用TensorFlow库.对于XOR门,我训练的唯一数据是完整的真值表,应该足够了吗?过度优化是我期望很快发生的事情.代码问题是权重和偏差不会更新.不知怎的,它仍然给我100%的准确度,偏差和重量为零.
x = tf.placeholder("float", [None, 2])
W = tf.Variable(tf.zeros([2,2]))
b = tf.Variable(tf.zeros([2]))
y = tf.nn.softmax(tf.matmul(x,W) + b)
y_ = tf.placeholder("float", [None,1])
print "Done init"
cross_entropy = -tf.reduce_sum(y_*tf.log(y))
train_step = tf.train.GradientDescentOptimizer(0.75).minimize(cross_entropy)
print "Done loading vars"
init = tf.initialize_all_variables()
print "Done: Initializing variables"
sess = tf.Session()
sess.run(init)
print "Done: Session started"
xTrain = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
yTrain = np.array([[1], [0], [0], [0]])
acc=0.0
while acc<0.85:
for i in range(500):
sess.run(train_step, feed_dict={x: xTrain, y_: …
Run Code Online (Sandbox Code Playgroud)