本文整理汇总了Python中tensorflow.python.lib.io.file_io.delete_file方法的典型用法代码示例。如果您正苦于以下问题:Python file_io.delete_file方法的具体用法?Python file_io.delete_file怎么用?Python file_io.delete_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.lib.io.file_io
的用法示例。
在下文中一共展示了file_io.delete_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: end
# 需要导入模块: from tensorflow.python.lib.io import file_io [as 别名]
# 或者: from tensorflow.python.lib.io.file_io import delete_file [as 别名]
def end(self, session):
if self.mode == tf.estimator.ModeKeys.EVAL:
current_global_step = session.run(self.global_step_tensor)
with open(os.path.join(self.writer.get_logdir(), "checkpoint")) as f:
checkpoints = [ckpt for ckpt in f]
checkpoints = [self.extract_global_step(ckpt) for ckpt in checkpoints[1:]]
checkpoints = list(filter(lambda gs: gs < current_global_step, checkpoints))
if len(checkpoints) > self.keep_eval_results_max_epoch:
checkpoint_to_delete = checkpoints[-self.keep_eval_results_max_epoch]
tf.logging.info("Deleting %s results at the step %d", self.mode, checkpoint_to_delete)
tfrecord_filespec = os.path.join(self.writer.get_logdir(),
"eval_result_step{:09d}_*.tfrecord".format(checkpoint_to_delete))
alignment_filespec = os.path.join(self.writer.get_logdir(),
"alignment_eval_result_step{:09d}_*.png".format(
checkpoint_to_delete))
mel_filespec = os.path.join(self.writer.get_logdir(),
"mel_eval_result_step{:09d}_*.png".format(checkpoint_to_delete))
for pathname in tf.gfile.Glob([tfrecord_filespec, alignment_filespec, mel_filespec]):
file_io.delete_file(pathname)
示例2: _delete_file_if_exists
# 需要导入模块: from tensorflow.python.lib.io import file_io [as 别名]
# 或者: from tensorflow.python.lib.io.file_io import delete_file [as 别名]
def _delete_file_if_exists(self, filespec):
for pathname in file_io.get_matching_files(filespec):
file_io.delete_file(pathname)
示例3: create_object_test
# 需要导入模块: from tensorflow.python.lib.io import file_io [as 别名]
# 或者: from tensorflow.python.lib.io.file_io import delete_file [as 别名]
def create_object_test():
"""Verifies file_io's object manipulation methods ."""
starttime = int(round(time.time() * 1000))
dir_name = "%s/tf_gcs_test_%s" % (FLAGS.gcs_bucket_url, starttime)
print("Creating dir %s." % dir_name)
file_io.create_dir(dir_name)
# Create a file in this directory.
file_name = "%s/test_file.txt" % dir_name
print("Creating file %s." % file_name)
file_io.write_string_to_file(file_name, "test file creation.")
list_files_pattern = "%s/test_file*.txt" % dir_name
print("Getting files matching pattern %s." % list_files_pattern)
files_list = file_io.get_matching_files(list_files_pattern)
print(files_list)
assert len(files_list) == 1
assert files_list[0] == file_name
# Cleanup test files.
print("Deleting file %s." % file_name)
file_io.delete_file(file_name)
# Delete directory.
print("Deleting directory %s." % dir_name)
file_io.delete_recursively(dir_name)
示例4: _delete_file_if_exists
# 需要导入模块: from tensorflow.python.lib.io import file_io [as 别名]
# 或者: from tensorflow.python.lib.io.file_io import delete_file [as 别名]
def _delete_file_if_exists(self, filespec):
for pathname in file_io.get_matching_files(filespec):
s = os.stat(pathname)[stat.ST_MODE]
if not (s & stat.S_IWUSR): # skip read-only file
continue
file_io.delete_file(pathname)