这可能是张量流初学者的问题。
我有一个组合trainX(training)
和trainY(answer)
,testX
和testY
以及单furtureX
(预测未来Y)
然后我的体重为w_h
,b_h
,w
,b
w_h = tf.Variable(tf.truncated_normal([companys,n_hidden],stddev=0.001))
b_h = tf.Variable(tf.zeros([n_hidden]))
w = tf.Variable(tf.truncated_normal([n_hidden,1],stddev=0.001))
b = tf.Variable(tf.zeros([1]))
x = tf.placeholder(tf.float32,shape=[None,companys]) # change dimensions to 2 -> 10
t = tf.placeholder(tf.float32,shape=[None,1])
h = tf.nn.relu(tf.matmul(x,w_h) + b_h)
y = tf.matmul(h,w) + b
cross_entropy = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=y,labels=t))
train_step = tf.train.GradientDescentOptimizer(0.1).minimize(cross_entropy)
correct_prediction = tf.equal(tf.to_float(tf.greater(y,0.5)),t)
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
for epoch in range(20000):
sess.run(train_step,feed_dict={
x: trainX,
t: trainY
})
if epoch % 1000 == 0:
trainAcc = sess.run(accuracy, feed_dict={x: trainX, t: trainY})
testAcc = sess.run(accuracy, feed_dict={x: testX, t: testY})
print ("accuracy at %s train:%.3f test:%.3f" % (epoch, trainAcc,testAcc))
#successfully get the final `weight` here
bIn = sess.run(b)
wIn = sess.run(w)
bHide = sess.run(b_h)
wHide = sess.run(w_h)
pprint(bIn)
pprint(wIn)
pprint(bHide)
pprint(wHide)
#I want to get the final data from `futureX`
现在,有了最后的重量',我想从futureX
预测未来。
我应该使用什么样的功能?
我为初学者阅读了很多书,并了解如何列出培训和测试数据,但是 无法找到预测未来的方法..