當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。