Python 什么是tensorflow哈希函数?

Python 什么是tensorflow哈希函数?,python,tensorflow,Python,Tensorflow,是描述TensorFlow的tf.string\u to\u hash\u bucket\u fast的页面。(当前版本为1.3。)它说定义此函数的文件是tensorflow/python/ops/gen_string_ops.py,它在github上似乎不存在。gen可能意味着它已生成。好的 此函数的可靠定义是什么(即,如果需要,我可以在其他平台上重新实现)?基于来自的注册信息。 我认为tf.string\u to\u hash\u bucket\u fast的实现是在相应的.h文件中实现的。

是描述TensorFlow的
tf.string\u to\u hash\u bucket\u fast的页面
。(当前版本为1.3。)它说定义此函数的文件是
tensorflow/python/ops/gen_string_ops.py
,它在github上似乎不存在。
gen
可能意味着它已生成。好的


此函数的可靠定义是什么(即,如果需要,我可以在其他平台上重新实现)?

基于来自的注册信息。
我认为
tf.string\u to\u hash\u bucket\u fast的实现是在相应的.h文件中实现的。

是的,该文件是在安装Tensorflow后生成的,因此您可以在该路径的计算机中找到它。对我来说,它位于这里:

/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen\u-string\u-ops.py

PS:当您遇到错误时,您可以看到这样的路径

实体定义为:

def string_to_hash_bucket(string_tensor, num_buckets, name=None):
  r"""Converts each string in the input Tensor to its hash mod by a number of buckets.

  The hash function is deterministic on the content of the string within the
  process.

  Note that the hash function may change from time to time.
  This functionality will be deprecated and it's recommended to use
  `tf.string_to_hash_bucket_fast()` or `tf.string_to_hash_bucket_strong()`.

  Args:
    string_tensor: A `Tensor` of type `string`.
    num_buckets: An `int` that is `>= 1`. The number of buckets.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `int64`.
    A Tensor of the same shape as the input `string_tensor`.
  """
  result = _op_def_lib.apply_op("StringToHashBucket",
                                string_tensor=string_tensor,
                                num_buckets=num_buckets, name=name)
  return result

您可以在
/usr/local/lib/python2.7/dist-packages/
下跟踪所需内容(这取决于您的设置)。绝对地说,Python定义不是真正的定义,而真正的定义是在前面的答案中明确表达的C++。p> 只是在前面所有答案的基础上进行构建:最终,您将通过以下导入来结束本文,其中包括: