Python 如何在神经网络训练过程中显示预测值

Python 如何在神经网络训练过程中显示预测值,python,tensorflow,neural-network,Python,Tensorflow,Neural Network,我正在训练一个模型,将视频剪辑从两个标签中分类,而模型丢失保持不变,因此我想知道训练进行时的预测值,我尝试了一下,然后出现了错误: Cannot assign a device for operation 'replica_1_5/model_12/activation_7/Softmax': Could not satisfy explicit device specification '/device:GPU:1' because no supported kernel for GPU de

我正在训练一个模型,将视频剪辑从两个标签中分类,而模型丢失保持不变,因此我想知道训练进行时的预测值,我尝试了一下,然后出现了错误:

Cannot assign a device for operation 'replica_1_5/model_12/activation_7/Softmax': Could not satisfy explicit device specification '/device:GPU:1' because no supported kernel for GPU devices is available.
Registered kernels:
device='CPU'; T in [DT_HALF]
device='CPU'; T in [DT_FLOAT]
device='CPU'; T in [DT_DOUBLE]
[[Node: replica_1_5/model_12/activation_7/Softmax = Softmax[T=DT_FLOAT, _device="/device:GPU:1"](replica_1_5/model_12/dense_21/BiasAdd)]]

During handling of the above exception, another exception occurred:
...
...
<ipython-input-29-a6bbc0e2d9db> in tf_loss(gen, ground)
    110 def tf_loss(gen,ground):
    111     with tf.Session() as sess:
--> 112         print(' gen:',sess.run(gen),' ground:',sess.run(ground))
    113     return K.binary_crossentropy(gen,ground)
    114 

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
    898     try:
    899       result = self._run(None, fetches, feed_dict, options_ptr,
--> 900                          run_metadata_ptr)
    901       if run_metadata:
    902         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1133     if final_fetches or final_targets or (handle and feed_dict_tensor):
   1134       results = self._do_run(handle, final_targets, final_fetches,
-> 1135                              feed_dict_tensor, options, run_metadata)
   1136     else:
   1137       results = []
...


可能是因为GPU不支持tf.Session(),我不确定~~

parallel_model.compile(loss=tf_loss, optimizer=Adam(lr=1e-4), metrics=['accuracy'])
def tf_loss(gen,ground):
    with tf.Session() as sess:
        print(' gen:',sess.run(gen),' ground:',sess.run(ground))
    return K.binary_crossentropy(gen,ground)