2016-08-18 5 views
1

바이너리 분류 작업에 다음과 같은 tensorflow 구현을 사용했는데 정말 정확도가 떨어졌습니다. 그러나 튜닝없이 sklearn.ensemble.GradientBoostingClassifier으로 동일한 데이터 세트를 교육했을 때 그 결과는 꽤 좋았습니다. 뉴런 네트워크의 샘플 밖에서의 예측을 자세히 살펴보면 대부분의 예측이 긍정적 인 클래스라는 것을 깨달았습니다.TensorFlow 이진 분류 작업의 정확도가 좋지 않지만 SciKit-Learn GBM이 잘 작동합니다.

  precision recall f1-score support 

     0  0.01  1.00  0.02   8 
     1  1.00  0.37  0.55  1630 

avg/total  1.00  0.38  0.54  1638 

2 층을 완전히 연결 네트워크의 구현 :

import math 
batch_size = 200 
feature_size = len(train_features.columns) 

graph = tf.Graph() 
with graph.as_default(): 

    # Input data. For the training data, we use a placeholder that will be fed 
    # at run time with a training minibatch. 
    tf_train_dataset = tf.placeholder(tf.float32, shape=(batch_size, feature_size)) 
    tf_train_labels = tf.placeholder(tf.float32, shape=(batch_size, num_labels)) 
    tf_valid_dataset = tf.constant(valid_dataset) 
    tf_test_dataset = tf.constant(test_dataset) 

    # Variables. 
    weights1 = tf.Variable(tf.truncated_normal([feature_size, 512])) 
    biases1 = tf.Variable(tf.zeros([512])) 

    weights2 = tf.Variable(tf.truncated_normal([512, 512], stddev=0.005)) 
    biases2 = tf.Variable(tf.zeros([512])) 

    weights = tf.Variable(tf.truncated_normal([512, num_labels], stddev=0.005)) 
    biases = tf.Variable(tf.zeros([num_labels])) 

    hidden_layer1 = tf.nn.relu(tf.matmul(tf_train_dataset, weights1) + biases1) 
    hidden_layer2 = tf.nn.relu(tf.matmul(hidden_layer1, weights2) + biases2) 
    logits = tf.matmul(hidden_layer2, weights) + biases 

    loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits, tf_train_labels)) 

    # Optimizer. 
    optimizer = tf.train.AdamOptimizer(0.0005).minimize(loss) 

    # Predictions for the training, validation, and test data. 
    train_prediction = tf.nn.softmax(logits) 

    valid_hidden_layer1 = tf.nn.relu(tf.matmul(tf_valid_dataset, weights1) + biases1) 
    valid_hidden_layer2 = tf.nn.relu(tf.matmul(valid_hidden_layer1, weights2) + biases2) 
    valid_prediction = tf.nn.softmax(tf.matmul(valid_hidden_layer2, weights) + biases) 

    test_hidden_layer1 = tf.nn.relu(tf.matmul(tf_test_dataset, weights1) + biases1) 
    test_hidden_layer2 = tf.nn.relu(tf.matmul(test_hidden_layer1, weights2) + biases2) 
    test_prediction = tf.nn.softmax(tf.matmul(test_hidden_layer2, weights) + biases) 

이를 디버깅하는 방법에 대한 어떤 제안?

답변

2

sklearn GradientBoostingClassifier는 신경망과 다른 알고리즘입니다. 신경망보다 우수한 성능을 제공하기 위해 미세 조정을 덜 필요로하는 회귀 트리를 기반으로합니다. 이것은 신경망을 사용할 때의 절충점입니다. 임의의 포리스트 및 SVM과 같은 대체 알고리즘보다 성능을 향상 시키려면 하이퍼 매개 변수를 조정해야합니다.

지금까지해야 할 일은 relu 단위의 바이어스를 0이 아닌 값으로 초기화하는 것입니다. 이것은 그들이 '죽을'정권에 들어가는 것을 막고 0 개의 출력과 0의 그라디언트를 영원히주는 것을 끝냅니다. 또한 다른 학습 속도를 시도해야합니다. 학습 속도가 너무 높으면 알고리즘이 제대로 학습되지 않으며 너무 낮 으면 리소스가 낭비됩니다.

또한 뉴런과 레이어의 수를 실험해야합니다. 각 숨겨진 레이어에 512 개의 뉴런이있는 것을 볼 수 있습니다. 문제가 차원이 높고 충분한 데이터가 없다면 너무 많은 것일 수 있습니다. 교육 및 테스트/교차 유효성 검사 오류는 무엇입니까? 당신은 훈련하는 동안 이것들을 추적해야합니다. 훈련 오류가 낮지 만 유효성 검증 오류가 높으면 overfitting 때문에 뉴런 수를 줄여야합니다. 또한 숨겨진 레이어를 하나만 사용하여 도움이되는지 확인할 수도 있습니다.

관련 문제