本文整理匯總了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)