def load_pipeline_proto(filename): """Load pipeline proto file. Args: filename: path to the pipeline proto file. Returns: pipeline_proto: an instance of pipeline_pb2.Pipeline """ def _revise_name(filename, offset): filename, postfix = filename.split('.record.') filename = '{}.record.{}'.format(filename, (int(postfix) + offset) % 10) return filename pipeline_proto = pipeline_pb2.Pipeline() with open(filename, 'r') as fp: text_format.Merge(fp.read(), pipeline_proto) if FLAGS.number_of_steps > 0: pipeline_proto.train_config.number_of_steps = FLAGS.number_of_steps pipeline_proto.eval_config.number_of_steps = FLAGS.number_of_steps pipeline_proto.example_reader.batch_size = 1 pipeline_proto.example_reader.num_epochs = 1 if FLAGS.split > -1: for _ in xrange(4): del pipeline_proto.example_reader.input_path[-1] n_files = len(pipeline_proto.example_reader.input_path) for i in xrange(n_files): pipeline_proto.example_reader.input_path[i] = _revise_name( pipeline_proto.example_reader.input_path[i], FLAGS.split + 8) return pipeline_proto
def _load_pipeline_proto(filename): """Loads pipeline proto from file. Args: filename: Path to the pipeline config file. Returns: An instance of pipeline_pb2.Pipeline. """ with tf.io.gfile.GFile(filename, 'r') as fp: return text_format.Merge(fp.read(), pipeline_pb2.Pipeline())
def load_pipeline_proto(filename): """Loads pipeline proto file. Args: filename: path to the pipeline proto file. Returns: pipeline_proto: an instance of pipeline_pb2.Pipeline """ pipeline_proto = pipeline_pb2.Pipeline() with open(filename, 'r') as fp: text_format.Merge(fp.read(), pipeline_proto) if FLAGS.number_of_steps > 0: pipeline_proto.train_config.number_of_steps = FLAGS.number_of_steps pipeline_proto.eval_config.number_of_steps = FLAGS.number_of_steps return pipeline_proto