Operating environment
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04 LTS desktop amd64
TensorFlow v1.1.0
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
bash> TFRerocds conversion of files in multiple directories (individual processing) http://qiita.com/7of9/items/6f6ffdb7dbcebdc8d923 Implementing the process of collecting TFRecords of multiple directories created in.
First, get the file list.
It seems to use glob. http://www.yukun.info/blog/2008/08/python-directory-listdir-glob.html Thank you for the information.
combine_TFRecords_170722.py
import glob
"""
v0.1 Jul. 22, 2017
- get file list
"""
# codingrule:PEP8
res = glob.glob("../run*/IntField-Y_170709.tfrecords")
for elem in res:
print(elem)
$ python3 combine_TFRecords_170722.py
../run366_sphere_g26_m1.45/IntField-Y_170709.tfrecords
../run375_sphere_g26_m1.5/IntField-Y_170709.tfrecords
../run354_sphere_g26_m1.33/IntField-Y_170709.tfrecords
../run362_sphere_g26_m1.4/IntField-Y_170709.tfrecords
../run364_sphere_g26_m1.4/IntField-Y_170709.tfrecords
../run368_sphere_g26_m1.45/IntField-Y_170709.tfrecords
../run370_sphere_g26_m1.45/IntField-Y_170709.tfrecords
../run376_sphere_g26_m1.5/IntField-Y_170709.tfrecords
../run367_sphere_g26_m1.45/IntField-Y_170709.tfrecords
../run356_sphere_g26_m1.33/IntField-Y_170709.tfrecords
../run372_sphere_g26_m1.5/IntField-Y_170709.tfrecords
../run355_sphere_g26_m1.33/IntField-Y_170709.tfrecords
../run360_sphere_g26_m1.4/IntField-Y_170709.tfrecords
../run373_sphere_g26_m1.5/IntField-Y_170709.tfrecords
../run365_sphere_g26_m1.45/IntField-Y_170709.tfrecords
../run369_sphere_g26_m1.45/IntField-Y_170709.tfrecords
../run353_sphere_g26_m1.33/IntField-Y_170709.tfrecords
../run357_sphere_g26_m1.33/IntField-Y_170709.tfrecords
../run371_sphere_g26_m1.5/IntField-Y_170709.tfrecords
../run359_sphere_g26_m1.4/IntField-Y_170709.tfrecords
../run358_sphere_g26_m1.33/IntField-Y_170709.tfrecords
../run374_sphere_g26_m1.5/IntField-Y_170709.tfrecords
../run363_sphere_g26_m1.4/IntField-Y_170709.tfrecords
../run361_sphere_g26_m1.4/IntField-Y_170709.tfrecords
(Addition 2017/10/03)
Reference: https://stackoverflow.com/questions/6773584/how-is-pythons-glob-glob-ordered
The order in glob.glob () execution will be the same as ls -U
.
Use sort () to sort by modification time.
import os
sorted(glob.glob('*.png'), key=os.path.getmtime)
Recommended Posts