-2

나는 신기원이 10에서 15로 증가했지만 정확도에는 영향을 미치지 않았습니다. 두 번 모두 정확도는 49.3 % 였고 1.0의 손실이있었습니다.왜 신경망 정확도가 동일하게 유지됩니까?

왜 이런 식으로 행동하게 될지 궁금하십니까? 나는 TensorFlow와 깊은 학습에 익숙하지 않습니다.

def train_neural_network(x): 
    prediction = neural_network_model(x) 
    cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=prediction,labels=y)) 
    optimizer = tf.train.AdamOptimizer(learning_rate=0.001).minimize(cost) 
    with tf.Session() as sess: 
     sess.run(tf.global_variables_initializer()) 

     try: 
      epoch = int(open(tf_log,'r').read().split('\n')[-2]) + 1 
      print('STARTING:',epoch) 
     except: 
      epoch = 1 
     # this will track epochs using a log file 
     while epoch <= n_epochs: 
      if epoch != 1: 
       saver.restore(sess,"./model.ckpt") 
      epoch_loss = 1 
      with open('lexicon-2500-2638.pickle','rb') as f: 
       lexicon = pickle.load(f) 
       print("lexicon length: ", len(lexicon)) 
      with open('train_set_shuffled.csv', buffering=20000, encoding='latin-1') as f: 
       batch_x = [] 
       batch_y = [] 
       batches_run = 0 
       for line in f: 
        label = line.split(':::')[0] 
        tweet = line.split(':::')[1] 
        current_words = word_tokenize(tweet.lower()) 
        current_words = [lemmatizer.lemmatize(i) for i in current_words] 

        features = np.zeros(len(lexicon)) 

        for word in current_words: 
         if word.lower() in lexicon: 
          index_value = lexicon.index(word.lower()) 

          features[index_value] += 1 
        line_x = list(features) 
        line_y = eval(label) 
        batch_x.append(line_x) 
        batch_y.append(line_y) 
        if len(batch_x) >= batch_size: 
         _, c = sess.run([optimizer, cost], feed_dict={x: np.array(batch_x), 
                     y: np.array(batch_y)}) 
         epoch_loss += c 
         batch_x = [] 
         batch_y = [] 
         batches_run += 1 
         print('Batch run:',batches_run,'/',total_batches,'| Epoch:',epoch,'| Batch Loss:',c,) 

      saver.save(sess, "./model.ckpt") 
      print('Epoch',epoch,'completed out of',n_epochs,'loss:',epoch_loss) 
      with open(tf_log,'a') as f: 
       f.write(str(epoch) + '\n') 
      epoch += 1 
    train_neural_network(x) 
+0

학습 데이터로 네트워크에 전달하는 것은 무엇입니까? 입력 내용과 레이블의 예를 보여줄 수 있습니까? 또한 각 교육 배치에 포함 된 내용을 간략하게 보여줄 수 있습니까? 사전이 얼마나 큽니까? 얼마나 많은 데이터를 교육하고 있습니까? –

+0

순수한 tensorflow보다 tensorflow 백엔드가있는 Keras를 사용하는 것이 더 좋습니다. – Nickpick

답변

1

신경 그물의 효율성에 기여하는 신 (新) 시대의 # 이외의 다른 매개 변수의 전체 호스트가있다 :

다음은 교육 방법입니다.

첫 번째 패스 시도로

, 당신은 실험을 시도 할 수도 있습니다 :

  • 다른 배치 (즉, 층의 # 증가)하여 신경망의
  • 다른 아키텍처 크기.
  • 다른 기능 변환 (즉, 아마도 lemmatizing 대신에 따른 시도)

이 더 많은 당신이 할 수있다, 나는 당신이 primer

행운을 확인하는 것이 좋습니다! :)

관련 문제