title: Tensorflow kernel dies and restarts automatically in jupyter with python 2.7
body: <p>Kernal dies automatically in jupyter for the following code and also in background python 2.7 unexpectedelly closes. What is the solution? Is this problem with python or jupyter itself? Somewhere I found that batch size may cause the problem but I even reduced batch size from 256 to 32. So far no difference. </p>
  
  <pre><code>def train(X_train, y_train, X_val, y_val, batch_size, iterations=1000, learning_rate=0.5):
      x = tf.placeholder(tf.float32, [None, 784])
      w1 = tf.Variable(tf.zeros([784, 100]))
      b1 = tf.Variable(tf.zeros([100]))
     #a1 = tf.placeholder(tf.float32, [None, 100])
      w2 = tf.Variable(tf.zeros([100, 11]))
      b2 = tf.Variable(tf.zeros([11]))
      y_ = tf.placeholder(tf.float32, [None, 11])
  
      z1 = tf.matmul(x, w1) + b1
      a1 = tf.nn.relu(z1)
      y = tf.matmul(a1, w2) + b2
  
      cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y))
      train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cross_entropy)
  
      correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
      accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
  
  
      sess = tf.InteractiveSession()
      tf.global_variables_initializer().run()
  
      #train
      parameters = {}
      i = 0
      j = batch_size
      for k in range(iterations):
          batch_x = X_train[i:j,:]
          batch_y = y_train[i:j,:]
          print batch_x.shape
          print batch_y.shape
          i += batch_size 
          j += batch_size 
          if(i &gt; X_train.shape[0] or j &gt; y_train.shape[0]):
               i += batch_size % X_train.shape[0]
               j += batch_size % y_train.shape[0]
          sess.run(train_step, feed_dict={x: batch_x, y_: batch_y})
          if( k % 100 == 0):
              print(sess.run(accuracy, feed_dict={x: X_val, y_: y_val}))
  
      parameters = {"w1": w1,
                 "b1": b1,
                 "w2": w2,
                 "b2": b2
      }
      return parameters
  </code></pre>