我试图使用深度神经网络架构来对二进制标签值 - 0和+1进行分类.这是我在tensorflow中执行此操作的代码.此问题也从前一个问题的讨论中得出结论
import tensorflow as tf
import numpy as np
from preprocess import create_feature_sets_and_labels
train_x,train_y,test_x,test_y = create_feature_sets_and_labels()
x = tf.placeholder('float', [None, 5])
y = tf.placeholder('float')
n_nodes_hl1 = 500
n_nodes_hl2 = 500
# n_nodes_hl3 = 500
n_classes = 1
batch_size = 100
def neural_network_model(data):
hidden_1_layer = {'weights':tf.Variable(tf.random_normal([5, n_nodes_hl1])),
'biases':tf.Variable(tf.random_normal([n_nodes_hl1]))}
hidden_2_layer = {'weights':tf.Variable(tf.random_normal([n_nodes_hl1, n_nodes_hl2])),
'biases':tf.Variable(tf.random_normal([n_nodes_hl2]))}
# hidden_3_layer = {'weights':tf.Variable(tf.random_normal([n_nodes_hl2, n_nodes_hl3])),
# 'biases':tf.Variable(tf.random_normal([n_nodes_hl3]))}
# output_layer = {'weights':tf.Variable(tf.random_normal([n_nodes_hl3, n_classes])),
# 'biases':tf.Variable(tf.random_normal([n_classes]))}
output_layer = {'weights':tf.Variable(tf.random_normal([n_nodes_hl2, n_classes])),
'biases':tf.Variable(tf.random_normal([n_classes]))}
l1 = tf.add(tf.matmul(data, hidden_1_layer['weights']), hidden_1_layer['biases']) …Run Code Online (Sandbox Code Playgroud) python machine-learning neural-network logistic-regression tensorflow