简体   繁体   English

没有注册任何OpKernel支持这些属性的Op'HashTableV2'。 注册设备:[CPU,GPU],注册内核:

[英]No OpKernel was registered to support Op 'HashTableV2' with these attrs. Registered devices: [CPU,GPU], Registered kernels:

I am coding with tensorflow 1.5.0, python 3.5. 我正在使用tensorflow 1.5.0,python 3.5进行编码。 I want to create a hashtable. 我想创建一个哈希表。 Since I intend to assign values to it later, I create it in the init function like this.(the values and shape are randomly given) enter image description here 由于我打算稍后为其分配值,因此我会在init函数中像这样创建它(值和形状是随机给出的) 在此处输入图像描述

but then I encounter a problem like this enter image description here 但是然后我遇到这样的问题在这里输入图片说明

Can anyone help me? 谁能帮我?

It seems that the implementation of HashTable in your version of TensorFlow does not provide kernels for every possible combination of key and value types. 在您的TensorFlow版本中,HashTable的实现似乎并未为键和值类型的每种可能组合提供内核。 There are two things you can do: 您可以做两件事:

  • According to your error message, there is a kernel implementation for 64-bit integer keys and 32-bit float values. 根据您的错误消息,对于64位整数键和32位浮点值,有一个内核实现。 So one possible fix is to simply change the data type of keys to tf.int64 : 因此,一种可能的解决方法是简单地将keys的数据类型更改为tf.int64

     keys = tf.constant([1, 2, 3]), dtype=tf.int64) 
  • Another possibility is to update TensorFlow to a version where this combination of key and value is implemented. 另一种可能性是将TensorFlow更新为实现键和值的组合的版本。 It seems this was added in version v1.11.0-rc0 ( see commmit ), so upgrading to that or a later version (in general it is more recommendable to upgrade to a stable version instead of a release candidate) should also fix the problem. 看来这是在v1.11.0-rc0版本中添加的请参阅commmit ),因此升级到该版本或更高版本(通常更建议升级到稳定版本而不是候选版本)也应该可以解决该问题。

The answers by @jdehesa is really great. @jdehesa的答案确实很棒。 It works for me!!! 这个对我有用!!! my tf version is 1.4, python=3.6 我的tf版本是1.4,python = 3.6

Here is my code which works: 这是我的代码有效:

import tensorflow as tf
from tensorflow.contrib.lookup import *

k = tf.range(1, 3, dtype=tf.int64)
v = tf.range(5, 7, dtype=tf.int64)
table = tf.contrib.lookup.HashTable(
    tf.contrib.lookup.KeyValueTensorInitializer(k, v, key_dtype=tf.int64, value_dtype=tf.int64), -1)

out = table.lookup(tf.constant([2,1], dtype=tf.int64))

with tf.Session() as sess:
    print(sess.run([k, v]))
    table.init.run()
    print(out.eval())

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TensorFlow缺少FFT的CPU Op(InvalidArgumentError:没有注册任何OpKernel支持这些属性的Op&#39;FFT&#39;) - TensorFlow missing CPU Op for FFT (InvalidArgumentError: No OpKernel was registered to support Op 'FFT' with these attrs) 加载Keras模型错误:没有注册任何Opternel支持这些属性的Op&#39;Assign&#39; - Loading Keras model error: No Opkernel was registered to support Op 'Assign' with these attrs 没有注册任何OpKernel支持这些属性的Op&#39;Conv2D&#39; - No OpKernel was registered to support Op 'Conv2D' with these attrs 没有注册 Opkernel 来支持 Op &#39;SparseSoftmaxCrossEntropyWithLogits&#39; - No Opkernel was registered to support Op 'SparseSoftmaxCrossEntropyWithLogits' NotFoundError:没有为与节点 {{node PyFunc}} 兼容的“CPU”设备注册的“PyFunc”OpKernel。 挂号的:<no registered kernels> - NotFoundError: No registered 'PyFunc' OpKernel for 'CPU' devices compatible with node {{node PyFunc}} . Registered: <no registered kernels> InvalidArgumentError:没有注册 OpKernel 来支持 Op 'CudnnRNN' - InvalidArgumentError: No OpKernel was registered to support Op 'CudnnRNN' InvalidArgumentError(请参阅上面的回溯):没有使用这些attrs注册任何OpKernel来支持Op&#39;MklConv2DWithBias&#39; - InvalidArgumentError (see above for traceback): No OpKernel was registered to support Op 'MklConv2DWithBias' with these attrs tensorflow 错误:恢复 model 时,“没有注册 OpKernel 以支持 Op 'TPUReplicatedInput'” - tensorflow error: "No OpKernel was registered to support Op 'TPUReplicatedInput'" when restoring model 没有注册具有这些属性的OpKernel支持Op&#39;L2Loss&#39;[[节点:L2Loss = L2Loss [T = DT_INT64](L2Loss / t)]] - No OpKernel was registered to support Op 'L2Loss' with these attrs [[Node: L2Loss = L2Loss[T=DT_INT64](L2Loss/t)]] 操作类型未在桌面上运行的二进制文件中注册“MaxBytesInUse” - Op type not registered 'MaxBytesInUse' in binary running on DESKTOP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM