python - 使用 tf.contrib.lookup 和 tf.python.ops.lookup_ops 的正确上下文是什么?
问题描述
我知道tf.contrib.lookup
并tf.python.ops.lookup_ops
包含相同的功能。tf.contrib.lookup.index_table_from_file
但是使用and之间有什么区别 tf.python.ops.lookup_ops.index_table_from_file
吗?我遇到了tf.python.ops.lookup_ops.index_table_from_file
在seq2seq 教程中使用的代码,所以我想知道为什么不使用它tf.contrib.lookup.index_table_from_file
呢?如果我想在我的代码中使用它,我应该使用哪一个?
解决方案
它们是相同的,tensorflow.contrib.lookup.lookup_ops.*
只是按原样导入tf.contrib.lookup
.
使用tf.contrib.lookup.*
而不是tf.python.ops.lookup_ops.*
,不仅因为它更短,而且仅仅是因为前者是官方python API的一部分,而不是后者。
至于他们为什么tf.python.ops.lookup_ops.index_table_from_file
直接在您提供的示例中使用,我不确定。也许他们觉得一个名为的文件utils/vocab_utils.py
是他们拥有的“内部”东西,可以绕过公共 API。恕我直言,这不是导入您自己的代码的做法。
推荐阅读
- python - 在硒中找不到任何元素
- python - 使用动态字符串变量调用 Python 函数
- apache-kafka - json消息的Kafka DLQ配置
- azure-web-app-service - Azure 不支持 ASP NET Core 5.0
- javascript - 如何从互联网连接虚拟机中的快速应用程序?
- python - 即使满足条件,显示消息语句也不会打印,我有点卡在这个上
- asp.net-core - 将 API 添加到现有 ASP.Net Core 2.2 MVC 解决方案的良好架构是什么
- python - 硒刮问题 | 拆分文本块以列出
- javascript - 如何设计和实现包含掩码的表单(类似于位掩码,但非二进制)?
- android - 在 Cmdline-tools 中找不到预制双簧管 REQUIRED CONFIG(版本 6858069)