当前位置: 首页>>代码示例>>Python>>正文


Python tensorflow.compat方法代码示例

本文整理汇总了Python中tensorflow.compat方法的典型用法代码示例。如果您正苦于以下问题:Python tensorflow.compat方法的具体用法?Python tensorflow.compat怎么用?Python tensorflow.compat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow的用法示例。


在下文中一共展示了tensorflow.compat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tf_summary_export

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import compat [as 别名]
def test_tf_summary_export(self):
        # Ensure that TF wasn't already imported, since we want this test to cover
        # the entire flow of "import tensorflow; use tf.summary" and if TF was in
        # fact already imported that reduces the comprehensiveness of the test.
        # This means this test has to be kept in its own file and that no other
        # test methods in this file should import tensorflow.
        self.assertEqual("notfound", sys.modules.get("tensorflow", "notfound"))
        import tensorflow as tf

        if not tf.__version__.startswith("2."):
            if hasattr(tf, "compat") and hasattr(tf.compat, "v2"):
                tf = tf.compat.v2
            else:
                self.skipTest("TF v2 summary API not available")
        # Check that tf.summary contains both TB-provided and TF-provided symbols.
        expected_symbols = frozenset(
            ["scalar", "image", "audio", "histogram", "text"]
            + ["write", "create_file_writer", "SummaryWriter"]
        )
        self.assertLessEqual(expected_symbols, frozenset(dir(tf.summary)))
        # Ensure we can dereference symbols as well.
        print(tf.summary.scalar)
        print(tf.summary.write) 
开发者ID:tensorflow,项目名称:tensorboard,代码行数:25,代码来源:tf_summary_test.py

示例2: __init__

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import compat [as 别名]
def __init__(self):
        modules = []
        if hasattr(tf_.compat, 'v1'):
            modules.append(tf_.compat.v1)

        self.modules = modules 
开发者ID:analysiscenter,项目名称:batchflow,代码行数:8,代码来源:__init__.py

示例3: import_tf

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import compat [as 别名]
def import_tf(cls):
        import tensorflow as tf

        # keep a reference to the v1 API as long as v2 provides compatibility
        tf1 = None
        tf_version = tf.__version__.split(".", 2)
        if tf_version[0] == "1":
            tf1 = tf
        elif getattr(tf, "compat", None) is not None and getattr(tf.compat, "v1", None) is not None:
            tf1 = tf.compat.v1

        return tf, tf1, tf_version 
开发者ID:riga,项目名称:law,代码行数:14,代码来源:formatter.py


注:本文中的tensorflow.compat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。