急切执行:tf.nn.lrn()-InternalError:找不到节点的有效设备

时间:2019-01-17 07:42:36

标签: python tensorflow conv-neural-network normalization

在启用InternalError后进行调试时,使用here中的tf.nn.lrn()的实现(经过小的修改)时,我得到了AlexNetEager Execution 。我在代码块的开头使用了tf.enable_eager_execution(),并在两帧视频上运行网络以查找错误。从计算开始就将所有输入强制转换为类型np.float64。我收到此错误

InternalError                             Traceback (most recent call last)
<ipython-input-17-cf3fc8cede61> in pseudo_alexnet(feats)
    146     conv_1 = tf.nn.bias_add(conv_1, biases["bc1"])
    147     conv_1 = tf.nn.relu(conv_1)
--> 148     conv_1 = tf.nn.local_response_normalization(tf.cast(conv_1, dtype = np.float64), depth_radius=5.0, bias=2.0, alpha=1e-4, beta=0.75)
    149     pool1 = max_pool_with_argmax(conv_1, filter_h = 3, filter_w = 3, stride_h = 2, stride_w = 2, name = 'pool1')
    150 

 ~\Anaconda3\envs\my_tensorflow_env\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py in lrn(input, depth_radius, bias, alpha, beta, name)
    4399       return lrn_eager_fallback(
    4400           input, depth_radius=depth_radius, bias=bias, alpha=alpha, beta=beta,
 -> 4401           name=name, ctx=_ctx)
    4402     except _core._NotOkStatusException as e:
    4403       if name is not None:

~\Anaconda3\envs\my_tensorflow_env\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py in lrn_eager_fallback(input, depth_radius, bias, alpha, beta, name, ctx)
    4430   "beta", beta, "T", _attr_T)
    4431   _result = _execute.execute(b"LRN", 1, inputs=_inputs_flat, attrs=_attrs,
 -> 4432                              ctx=_ctx, name=name)
    4433   _execute.record_gradient(
    4434       "LRN", _inputs_flat, _attrs, _result, name)

~\Anaconda3\envs\my_tensorflow_env\lib\site-packages\tensorflow\python\eager\execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
    64     else:
    65       message = e.message      
---> 66     six.raise_from(core._status_to_exception(e.code, message), None)
    67   # pylint: enable=protected-access
    68   return tensors

~\Anaconda3\envs\my_tensorflow_env\lib\site-packages\six.py in raise_from(value, from_value)

InternalError: Could not find valid device for node.
Node: {{node LRN}} = LRN[T=DT_DOUBLE, alpha=0.0001, beta=0.75, bias=2, depth_radius=5](dummy_input)
All kernels registered for op LRN :
   device='CPU'; T in [DT_FLOAT]
   device='CPU'; T in [DT_HALF]
  [Op:LRN]

1 个答案:

答案 0 :(得分:0)

错误是因为您尝试将输入数据类型为 float64 加载到 tf.nn.local_response_normalization

如果选中 tf.nn.local_response_normalization,则支持的输入类型为 half, bfloat16, float32

要解决您的问题,您可以使用 tf.cast 并将输入转换为 float32