title: How to transform tensors to numpy.ndarray in Keras?
body: <p>I have got a Tensorflow Tensor within Keras (&lt; class 'tensorflow.python.framework.ops.Tensor'>) which needs to be transformed into a numpy.ndarray. 
  Is there an easy solution to this task? </p>
  
  <p>I did time-comsuming research via Google and trial/error. 
  It seems that I have to use tensorflow sessions, but I don't wan't to use any tensorflow sessions, because using them I will receive errors like:</p>
  
  <pre><code>I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating 
  TensorFlow device (/gpu:0) -&gt; (device: 0, name: TITAN X (Pascal), pci bus id: 0000:09:00.0)
  I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:1) -&gt; (device: 1, name: TITAN X (Pascal), pci bus id: 0000:05:00.0)
  Traceback (most recent call last):
    File "mnist_cnn_model_api.py", line 348, in &lt;module&gt;
      validation_data=(X_test, Y_test))
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1596, in fit_generator
      callbacks.on_epoch_end(epoch, epoch_logs)
    File "/usr/local/lib/python2.7/dist-packages/keras/callbacks.py", line 76, in on_epoch_end
      callback.on_epoch_end(epoch, logs)
    File "/home/dominik/keras/mnist/my_functions.py", line 737, in on_epoch_end
      current_ist = current_is.eval()
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 575, in eval
      return _eval_using_default_session(self, feed_dict, self.graph, session)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3633, in _eval_using_default_session
      return session.run(tensors, feed_dict)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 766, in run
      run_metadata_ptr)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 964, in _run
      feed_dict_string, options, run_metadata)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1014, in _do_run
      target_list, options, run_metadata)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1034, in _do_call
      raise type(e)(node_def, op, message)
  tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'input_1' with dtype float
       [[Node: input_1 = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/gpu:0"]()]]
       [[Node: strided_slice_1/_1 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_6_strided_slice_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
  
  Caused by op u'input_1', defined at:
    File "mnist_cnn_model_api.py", line 113, in &lt;module&gt;
      inputs = Input(shape=input_shape)
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 1198, in Input
      input_tensor=tensor)
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 1116, in __init__
      name=self.name)
    File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 309, in placeholder
      x = tf.placeholder(dtype, shape=shape, name=name)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1587, in placeholder
      name=name)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2043, in _placeholder
      name=name)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
      op_def=op_def)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
      original_op=self._default_original_op, op_def=op_def)
    File "/home/dominik/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1128, in __init__
      self._traceback = _extract_stack()
  
  InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'input_1' with dtype float
       [[Node: input_1 = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/gpu:0"]()]]
       [[Node: strided_slice_1/_1 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_6_strided_slice_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
  </code></pre>
  
  <p>I need this placeholder in line 113 - it doesn't make troubles when using Keras without any tensorflow session. But as soon as I am trying to use a tensorflow session (in order to use .eval() for transforming the tensor into numpy.ndarray) my code explodes...</p>
  
  <p>I appreciate your help!</p>