def test_init_from_checkpoint_global_step(self):
    'Tests that a simple model trains and exported models are valid.'
    gin.bind_parameter('tf.estimator.RunConfig.save_checkpoints_steps', 100)
    gin.bind_parameter('tf.estimator.RunConfig.keep_checkpoint_max', 3)
    model_dir = self.create_tempdir().full_path
    mock_t2r_model = mocks.MockT2RModel(preprocessor_cls=noop_preprocessor.NoOpPreprocessor)
    mock_input_generator_train = mocks.MockInputGenerator(batch_size=_BATCH_SIZE)
    train_eval.train_eval_model(t2r_model=mock_t2r_model, input_generator_train=mock_input_generator_train, max_train_steps=_MAX_TRAIN_STEPS, model_dir=model_dir, eval_steps=_EVAL_STEPS, eval_throttle_secs=_EVAL_THROTTLE_SECS, create_exporters_fn=train_eval.create_default_exporters)
    self.assertLen(tf.io.gfile.glob(os.path.join(model_dir, 'model*.meta')), 3)
    continue_model_dir = self.create_tempdir().full_path
    init_from_checkpoint_fn = functools.partial(abstract_model.default_init_from_checkpoint_fn, checkpoint=model_dir)
    continue_mock_t2r_model = mocks.MockT2RModel(preprocessor_cls=noop_preprocessor.NoOpPreprocessor, init_from_checkpoint_fn=init_from_checkpoint_fn)
    continue_mock_input_generator_train = mocks.MockInputGenerator(batch_size=_BATCH_SIZE)
    train_eval.train_eval_model(t2r_model=continue_mock_t2r_model, input_generator_train=continue_mock_input_generator_train, model_dir=continue_model_dir, max_train_steps=(_MAX_TRAIN_STEPS + 100), eval_steps=_EVAL_STEPS, eval_throttle_secs=_EVAL_THROTTLE_SECS, create_exporters_fn=train_eval.create_default_exporters)
    self.assertLen(tf.io.gfile.glob(os.path.join(continue_model_dir, 'model*.meta')), 2)
Tests that a simple model trains and exported models are valid.
def test_init_from_checkpoint_global_step(self):
    
    gin.bind_parameter('tf.estimator.RunConfig.save_checkpoints_steps', 100)
    gin.bind_parameter('tf.estimator.RunConfig.keep_checkpoint_max', 3)
    model_dir = self.create_tempdir().full_path
    mock_t2r_model = mocks.MockT2RModel(preprocessor_cls=noop_preprocessor.NoOpPreprocessor)
    mock_input_generator_train = mocks.MockInputGenerator(batch_size=_BATCH_SIZE)
    train_eval.train_eval_model(t2r_model=mock_t2r_model, input_generator_train=mock_input_generator_train, max_train_steps=_MAX_TRAIN_STEPS, model_dir=model_dir, eval_steps=_EVAL_STEPS, eval_throttle_secs=_EVAL_THROTTLE_SECS, create_exporters_fn=train_eval.create_default_exporters)
    self.assertLen(tf.io.gfile.glob(os.path.join(model_dir, 'model*.meta')), 3)
    continue_model_dir = self.create_tempdir().full_path
    init_from_checkpoint_fn = functools.partial(abstract_model.default_init_from_checkpoint_fn, checkpoint=model_dir)
    continue_mock_t2r_model = mocks.MockT2RModel(preprocessor_cls=noop_preprocessor.NoOpPreprocessor, init_from_checkpoint_fn=init_from_checkpoint_fn)
    continue_mock_input_generator_train = mocks.MockInputGenerator(batch_size=_BATCH_SIZE)
    train_eval.train_eval_model(t2r_model=continue_mock_t2r_model, input_generator_train=continue_mock_input_generator_train, model_dir=continue_model_dir, max_train_steps=(_MAX_TRAIN_STEPS + 100), eval_steps=_EVAL_STEPS, eval_throttle_secs=_EVAL_THROTTLE_SECS, create_exporters_fn=train_eval.create_default_exporters)
    self.assertLen(tf.io.gfile.glob(os.path.join(continue_model_dir, 'model*.meta')), 2)