vgsl_train.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright 2016 The TensorFlow Authors. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ==============================================================================
  15. """Model trainer for single or multi-replica training."""
  16. from tensorflow import app
  17. from tensorflow.python.platform import flags
  18. import vgsl_model
  19. flags.DEFINE_string('master', '', 'Name of the TensorFlow master to use.')
  20. flags.DEFINE_string('train_dir', '/tmp/mdir',
  21. 'Directory where to write event logs.')
  22. flags.DEFINE_string('model_str',
  23. '1,150,600,3[S2(4x150)0,2 Ct5,5,16 Mp2,2 Ct5,5,64 Mp3,3'
  24. '([Lrys64 Lbx128][Lbys64 Lbx128][Lfys64 Lbx128])S3(3x0)2,3'
  25. 'Lfx128 Lrx128 S0(1x4)0,3 Do Lfx256]O1c134',
  26. 'Network description.')
  27. flags.DEFINE_integer('max_steps', 10000, 'Number of steps to train for.')
  28. flags.DEFINE_integer('task', 0, 'Task id of the replica running the training.')
  29. flags.DEFINE_integer('ps_tasks', 0, 'Number of tasks in the ps job.'
  30. 'If 0 no ps job is used.')
  31. flags.DEFINE_string('train_data', None, 'Training data filepattern')
  32. flags.DEFINE_float('initial_learning_rate', 0.00002, 'Initial learning rate')
  33. flags.DEFINE_float('final_learning_rate', 0.00002, 'Final learning rate')
  34. flags.DEFINE_integer('learning_rate_halflife', 1600000,
  35. 'Halflife of learning rate')
  36. flags.DEFINE_string('optimizer_type', 'Adam',
  37. 'Optimizer from:GradientDescent, AdaGrad, Momentum, Adam')
  38. flags.DEFINE_integer('num_preprocess_threads', 4, 'Number of input threads')
  39. FLAGS = flags.FLAGS
  40. def main(argv):
  41. del argv
  42. vgsl_model.Train(FLAGS.train_dir, FLAGS.model_str, FLAGS.train_data,
  43. FLAGS.max_steps, FLAGS.master, FLAGS.task, FLAGS.ps_tasks,
  44. FLAGS.initial_learning_rate, FLAGS.final_learning_rate,
  45. FLAGS.learning_rate_halflife, FLAGS.optimizer_type,
  46. FLAGS.num_preprocess_threads)
  47. if __name__ == '__main__':
  48. app.run()