【发布时间】:2020-12-26 11:01:35
【问题描述】:
我正在使用 Tensorflow 处理 CNN 回归模型。我想知道是否可以使用回归从我的数据集中估计多个数据? (换句话说,我想使用头部和双手的位置和旋转来估计人体肩部和肘部的位置(x,y,z)和旋转(pitch,yaw,roll))
所以,我的模型的输出应该是每个关节的 6 个值。 (例如:肘部) 这也是我的代码示例:(我使用 tf.session 来训练模型)
# define placeholder for inputs to network
xs = tf.placeholder(tf.float32, [None, 42], name ='input_node')
ys = tf.placeholder(tf.float32, [None, 1])
keep_prob = tf.placeholder(tf.float32)
#Network computations and Layers
x_image = tf.reshape(xs, [-1, 3, 3,1])
## conv1 layer
W_conv1 = weight_func([3, 3, 1, 32])
b_conv1 = bias_func([32])
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
h_pool1 = max_pool_2x2(h_conv1)
# h_drop1 = tf.nn.dropout(h_conv1, keep_prob)
## conv2 layer
W_conv2 = weight_func([3, 3, 32, 64])
b_conv2 = bias_func([64])
h_conv2 = tf.nn.relu(conv2d(h_conv1, W_conv2) + b_conv2)
# h_drop2 = tf.nn.dropout(h_conv2, keep_prob)
## conv3 layer
W_conv3 = weight_func([3, 3, 64, 128])
b_conv3 = bias_func([128])
h_conv3 = tf.nn.relu(conv2d(h_conv2, W_conv3) + b_conv3)
# h_drop3 = tf.nn.dropout(h_conv3, keep_prob)
## conv4 layer
W_conv4 = weight_func([3, 3, 128,256])
b_conv4 = bias_func([256])
h_conv4 = tf.nn.relu(conv2d(h_conv3, W_conv4) + b_conv4)
# h_drop4 = tf.nn.dropout(h_conv4, keep_prob)
## fc1 layer
W_fc1 = weight_func([3 * 3 * 256, 2304])
b_fc1 = bias_func([256])
h_pool2_flat = tf.reshape(h_conv4, [-1, 3* 3 * 256])
h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1)
h_fc1_drop = tf.nn.dropout(h_fc1, keep_prob)
# fc2 layer ## full connection
W_fc2 = weight_func([2304, 1])
b_fc2 = bias_func([1])
prediction = tf.add(tf.matmul(h_fc1_drop, W_fc2) , b_fc2, name= 'output_node')
cross_entropy = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction), reduction_indices=[1]))
sess = tf.Session()
train_step = tf.train.AdamOptimizer(0.01).minimize(cross_entropy)
sess.run(tf.global_variables_initializer())
init=tf.global_variables_initializer()
for i in range(50):
sess.run([train_step] , feed_dict = {xs: train_x, ys: train_y, keep_prob: 0.7})
prediction_value = sess.run(prediction, feed_dict={xs: test_x, ys: test_y, keep_prob: 1.0})`
【问题讨论】:
-
@AniketBote 不,它不起作用。
标签: tensorflow regression orientation supervised-learning estimation