2017-06-23 6 views
0

私はUdacity Deep Learningクラスを勉強しています。その宿題は「過度の過度の場合を示します。トレーニングデータをほんの数バッチに制限してください。ステップ、バッチサイズin Gradient Descent Tensorflow

私の質問は:

1) はなぜnum_steps, num_batchesがオーバーフィッティングを行うには何も持って減らすん?変数を追加したり、Wのサイズを増やしたりすることはありません。

以下のコードでは、num_stepsは3001、num_batchesは128であり、ソリューションではそれぞれ101と3に減少しています。

num_steps = 101 
    num_bacthes = 3 

    with tf.Session(graph=graph) as session: 
     tf.initialize_all_variables().run() 
     print("Initialized") 
     for step in range(num_steps): 
     # Pick an offset within the training data, which has been randomized. 
     # Note: we could use better randomization across epochs. 
     #offset = (step * batch_size) % (train_labels.shape[0] - batch_size) 
     offset = step % num_bacthes 
     # Generate a minibatch. 
     batch_data = train_dataset[offset:(offset + batch_size), :] 
     batch_labels = train_labels[offset:(offset + batch_size), :] 
     # Prepare a dictionary telling the session where to feed the minibatch. 
     # The key of the dictionary is the placeholder node of the graph to be fed, 
     # and the value is the numpy array to feed to it. 
     feed_dict = {tf_train_dataset : batch_data, tf_train_labels : batch_labels, beta_regul : 1e-3} 
     _, l, predictions = session.run(
      [optimizer, loss, train_prediction], feed_dict=feed_dict) 
     if (step % 2 == 0): 
      print("Minibatch loss at step %d: %f" % (step, l)) 
      print("Minibatch accuracy: %.1f%%" % accuracy(predictions, batch_labels)) 
      print("Validation accuracy: %.1f%%" % accuracy(
      valid_prediction.eval(), valid_labels)) 
     print("Test accuracy: %.1f%%" % accuracy(test_prediction.eval(), test_labels)) 

このコードは、溶液からの抜粋です:https://github.com/rndbrtrnd/udacity-deep-learning/blob/master/3_regularization.ipynb

2)誰かが、勾配降下中に「オフセット」の概念を説明することはできますか?なぜそれを使わなければならないのですか?

3)私はnum_stepsを実験して、num_stepsを大きくすると精度が上がることを発見しました。どうして? num_stepを学習率でどのように解釈すればよいですか?

答えて

1

1)オーバーフィットを防ぐためにニューラルネットワークをトレーニングするときは、早期停止条件を設定するのが一般的です。あなたは新しい変数を追加するつもりはありませんが、初期の停止条件を使用すると、それらを集中的に使いこなすことはできません。

2)ここで「オフセット」minibatchで使用されていない残りの観測分割の(残りの)

3)「速度」と「学習率」と「時間」と「num_steps」と考えています。あなたが長く実行する場合は、さらに駆動することができる...しかし、あなたがより速くドライブならば、多分多分あなたはクラッシュし得る可能性があり、更に多く行かない...

関連する問題