小编sum*_*mit的帖子

预测分类器张量流中的概率

嘿,我对张量流还很陌生。我正在构建一个分类模型,基本上分类为 0/1。有没有办法预测输出为1的概率。这里可以使用predict_proba吗?它在 tflearn.dnn 中被广泛使用,但在我的例子中找不到任何参考。

def main():
    train_x,test_x,train_y,test_y = load_csv_data() 
    x_size = train_x.shape[1] 
    y_size = train_y.shape[1] 

    print(x_size)
    print(y_size)
    # variables
    X = tf.placeholder("float", shape=[None, x_size])
    y = tf.placeholder("float", shape=[None, y_size])
    weights_1 = initialize_weights((x_size, h_size))
    weights_2 = initialize_weights((h_size, y_size))
    # Forward propagation
    y_pred = forward_propagation(X, weights_1, weights_2)
    predict = tf.argmax(y_pred, dimension=1)
    # Backward propagation
    cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y, logits=y_pred))
    updates_sgd = tf.train.GradientDescentOptimizer(sgd_step).minimize(cost)
    # Start tensorflow session 

    with tf.Session() as sess:

        init = tf.global_variables_initializer()
        steps = 1
        sess.run(init)
        x  = np.arange(steps)
        test_acc = [] …
Run Code Online (Sandbox Code Playgroud)

classification machine-learning tensorflow

5
推荐指数
1
解决办法
9152
查看次数