本文整理匯總了Python中tensorflow.compat.v1.enable_eager_execution方法的典型用法代碼示例。如果您正苦於以下問題:Python v1.enable_eager_execution方法的具體用法?Python v1.enable_eager_execution怎麽用?Python v1.enable_eager_execution使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.compat.v1
的用法示例。
在下文中一共展示了v1.enable_eager_execution方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_main
# 需要導入模塊: from tensorflow.compat import v1 [as 別名]
# 或者: from tensorflow.compat.v1 import enable_eager_execution [as 別名]
def test_main():
tf.enable_eager_execution()
tf.test.main()
示例2: setUp
# 需要導入模塊: from tensorflow.compat import v1 [as 別名]
# 或者: from tensorflow.compat.v1 import enable_eager_execution [as 別名]
def setUp(self):
tf.enable_eager_execution()
super(DPOptimizerEagerTest, self).setUp()
示例3: main
# 需要導入模塊: from tensorflow.compat import v1 [as 別名]
# 或者: from tensorflow.compat.v1 import enable_eager_execution [as 別名]
def main(_):
flags.mark_flags_as_required(["task"])
if FLAGS.module_import:
import_modules(FLAGS.module_import)
gin.parse_config_files_and_bindings(FLAGS.gin_file, FLAGS.gin_param)
total_examples = 0
tf.enable_eager_execution()
task = t5.data.TaskRegistry.get(FLAGS.task)
files = task.tfds_dataset.files(FLAGS.split)
def _example_to_string(ex):
key_to_string = {}
for k in ("inputs", "targets"):
if k in ex:
v = ex[k].numpy()
key_to_string[k] = (
" ".join(str(i) for i in v) if FLAGS.tokenize
else v.decode("utf-8"))
else:
v[k] = ""
return FLAGS.format_string.format(**key_to_string)
for shard_path in files:
logging.info("Processing shard: %s", shard_path)
ds = task.tfds_dataset.load_shard(shard_path)
ds = task.preprocess_text(ds)
if FLAGS.tokenize:
ds = t5.data.encode_string_features(
ds, task.output_features, keys=task.output_features,
copy_plaintext=True)
ds = task.preprocess_tokens(ds, sequence_length())
for ex in ds:
print(_example_to_string(ex))
total_examples += 1
if total_examples == FLAGS.max_examples:
return