输入多个数据集以进行张量流模型的训练

时间:2017-07-27 15:06:22

标签: python tensorflow

我有数据集trainXtrainZ,这会导致trainY(回答)

例如

trainX
[[4,3,5,2],[4,5,3,4],[2,3,5,4]]    

trainZ
[[1,2,4,2],[2,1,3,2],[3,5,4,2]]

trainY (answer)
[[0],[1],[1]]

目前,我成功地将模型设为仅输入trainX [3x4]并获取trainY [1x3]作为答案

n_hidden = 50

w_h = tf.Variable(tf.truncated_normal([4,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,4]) 
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(trainingNum):
    sess.run(train_step,feed_dict={
        x: trainX,
        t: trainY
    })
    if epoch % 1000  == 0:
        trainAcc = sess.run(accuracy, feed_dict={x: trainX, t: trainY})

现在我想输入trainZ

我有两个想法,

1)以某种方式为trainZ和concatte结果制作另一个模型???

2)简单的concat(trainX,trainZ)数据帧??

哪个想法是正确的?

我害怕2虽然有点过于笨重......

我认为这是初学者在理解简单的深度学习结构后的第二步。

有没有好的参考或网站?

0 个答案:

没有答案